├── .cvsignore ├── .distfiles ├── .editorconfig ├── .github ├── .cspell │ ├── project-ignored.txt │ └── project-words.txt ├── LICENCE ├── README.md ├── dependabot.yml └── workflows │ ├── test-linux.yml │ └── test-macos.yml ├── .gitignore ├── .preconfig ├── .trunk ├── .gitignore ├── configs │ ├── .markdownlint.yaml │ ├── .shellcheckrc │ └── .yamllint.yaml └── trunk.yaml ├── .vscode └── settings.json ├── Config ├── .cvsignore ├── .distfiles ├── aczshoot.m4 ├── clean.mk ├── config.mk ├── defs.mk.in ├── installfns.sh ├── uninstallfns.sh └── version.mk ├── Makefile.in ├── RECOMPILE_REQUEST ├── Scripts ├── copy_from_zsh_src.zsh └── install.sh ├── Src ├── .cvsignore ├── .distfiles ├── .exrc ├── .indent.pro ├── Makefile.in ├── Makemod.in.in ├── builtin.c ├── compat.c ├── exec.c ├── glob.c ├── hashtable.c ├── hashtable.h ├── init.c ├── input.c ├── jobs.c ├── lex.c ├── loop.c ├── makepro.awk ├── mem.c ├── mkbltnmlst.sh ├── mkmakemod.sh ├── module.c ├── options.c ├── params.c ├── parse.c ├── pattern.c ├── prompt.c ├── prototypes.h ├── signals.c ├── signals.h ├── signames1.awk ├── signames2.awk ├── string.c ├── utils.c ├── wcwidth9.h ├── zi │ ├── .cvsignore │ ├── .distfiles │ ├── .exrc │ ├── zpmod.c │ └── zpmod.mdd ├── zsh.h ├── zsh.mdd ├── zsh.rc ├── zsh_system.h └── ztype.h ├── Test ├── .cvsignore ├── .distfiles ├── A01grammar.ztst ├── A02alias.ztst ├── A03quoting.ztst ├── A04redirect.ztst ├── A05execution.ztst ├── A06assign.ztst ├── A07control.ztst ├── B01cd.ztst ├── B02typeset.ztst ├── B03print.ztst ├── B04read.ztst ├── B05eval.ztst ├── B06fc.ztst ├── B07emulate.ztst ├── B08shift.ztst ├── B09hash.ztst ├── C01arith.ztst ├── C02cond.ztst ├── C03traps.ztst ├── C04funcdef.ztst ├── C05debug.ztst ├── D01prompt.ztst ├── D02glob.ztst ├── D03procsubst.ztst ├── D04parameter.ztst ├── D05array.ztst ├── D06subscript.ztst ├── D07multibyte.ztst ├── D08cmdsubst.ztst ├── D09brace.ztst ├── E01options.ztst ├── E02xtrace.ztst ├── Makefile.in ├── README ├── V02zregexparse.ztst ├── V03mathfunc.ztst ├── V04features.ztst ├── V05styles.ztst ├── V07pcre.ztst ├── V08zpty.ztst ├── V09datetime.ztst ├── V10private.ztst ├── V11db_gdbm.ztst ├── W01history.ztst ├── comptest ├── runtests.zsh └── ztst.zsh ├── Util └── preconfig ├── aclocal.m4 ├── aczsh.m4 ├── build.sh ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── install-sh ├── mkinstalldirs ├── patch_cfgac.diff └── stamp-h.in /.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | META-FAQ 3 | config.cache 4 | config.h 5 | config.h.in 6 | config.log 7 | config.modules 8 | config.modules.sh 9 | config.status 10 | configure 11 | cscope.out 12 | stamp-h 13 | stamp-h.in 14 | autom4te.cache 15 | *.swp 16 | .git 17 | -------------------------------------------------------------------------------- /.distfiles: -------------------------------------------------------------------------------- 1 | DISTFILES_SRC=' 2 | META-FAQ 3 | configure config.h.in stamp-h.in 4 | ' 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Space or Tabs? 2 | # https://stackoverflow.com/questions/35649847/objective-reasons-for-using-spaces-instead-of-tabs-for-indentation 3 | # https://stackoverflow.com/questions/12093748/how-to-use-tabs-instead-of-spaces-in-a-shell-script 4 | # https://github.com/editorconfig/editorconfig-defaults/blob/master/editorconfig-defaults.json 5 | # 6 | # 1. What happens when I press the Tab key in my text editor? 7 | # 2. What happens when I request my editor to indent one or more lines? 8 | # 3. What happens when I view a file containing U+0009 HORIZONTAL TAB characters? 9 | # 10 | # Answers: 11 | # 12 | # 1. Pressing the Tab key should indent the current line (or selected lines) one additional level. 13 | # 2. As a secondary alternative, I can also tolerate an editor that, 14 | # like Emacs, uses this key for a context-sensitive fix-my-indentation command. 15 | # 3. Indenting one or more lines should follow the reigning convention, if consensus is sufficiently strong; otherwise, 16 | # I greatly prefer 2-space indentation at each level. U+0009 characters should shift subsequent characters to the next tab stop. 17 | # 18 | # Note: VIM users should use alternate marks [[[ and ]]] as the original ones can confuse nested substitutions, e.g.: ${${${VAR}}} 19 | # 20 | # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- 21 | # vim: ft=zsh sw=2 ts=2 et 22 | 23 | root = true 24 | 25 | [*] 26 | charset = utf-8 27 | indent_style = space 28 | indent_size = 2 29 | insert_final_newline = true 30 | trim_trailing_whitespace = true 31 | 32 | [*.sln] 33 | indent_style = tab 34 | 35 | [*.{md,mdx,rst}] 36 | trim_trailing_whitespace = false 37 | 38 | [*.{cmd,bat}] 39 | end_of_line = crlf 40 | 41 | [*za-*] 42 | end_of_line = lf 43 | 44 | [*.{sh,bash,zsh,fish}] 45 | end_of_line = lf 46 | 47 | [Makefile] 48 | indent_style = tab 49 | indent_size = 4 50 | 51 | [*.{py,rb}] 52 | indent_size = 4 53 | 54 | [*.{go,java,scala,groovy,kotlin}] 55 | indent_style = tab 56 | indent_size = 4 57 | 58 | [*.{cs,csx,cake,vb,vbx}] 59 | # Default Severity for all .NET Code Style rules below 60 | dotnet_analyzer_diagnostic.severity = warning 61 | -------------------------------------------------------------------------------- /.github/.cspell/project-ignored.txt: -------------------------------------------------------------------------------- 1 | mhas 2 | mload 3 | pname 4 | -------------------------------------------------------------------------------- /.github/.cspell/project-words.txt: -------------------------------------------------------------------------------- 1 | autoheader 2 | automake 3 | CFLAGS 4 | CPPFLAGS 5 | distclean 6 | gdbm 7 | LDFLAGS 8 | libc 9 | sevent 10 | tcsetpgrp 11 | ZDOTDIR 12 | zmodload 13 | zmodules 14 | zpmod 15 | -------------------------------------------------------------------------------- /.github/LICENCE: -------------------------------------------------------------------------------- 1 | Unless otherwise noted in the header of specific files, files in this 2 | distribution have the licence shown below. 3 | 4 | However, note that certain shell functions are licensed under versions 5 | of the GNU General Public Licence. Anyone distributing the shell as a 6 | binary including those files needs to take account of this. Search 7 | shell functions for "Copyright" for specific copyright information. 8 | None of the core functions are affected by this, so those files may 9 | simply be omitted. 10 | 11 | -- 12 | 13 | The Z Shell is copyright (c) 1992-2017 Paul Falstad, Richard Coleman, 14 | Zoltán Hidvégi, Andrew Main, Peter Stephenson, Sven Wischnowsky, and 15 | others. All rights reserved. Individual authors, whether or not 16 | specifically named, retain copyright in all changes; in what follows, they 17 | are referred to as `the Zsh Development Group'. This is for convenience 18 | only and this body has no legal status. The Z shell is distributed under 19 | the following licence; any provisions made in individual files take 20 | precedence. 21 | 22 | Permission is hereby granted, without written agreement and without 23 | licence or royalty fees, to use, copy, modify, and distribute this 24 | software and to distribute modified versions of this software for any 25 | purpose, provided that the above copyright notice and the following 26 | two paragraphs appear in all copies of this software. 27 | 28 | In no event shall the Zsh Development Group be liable to any party for 29 | direct, indirect, special, incidental, or consequential damages arising out 30 | of the use of this software and its documentation, even if the Zsh 31 | Development Group have been advised of the possibility of such damage. 32 | 33 | The Zsh Development Group specifically disclaim any warranties, including, 34 | but not limited to, the implied warranties of merchantability and fitness 35 | for a particular purpose. The software provided hereunder is on an "as is" 36 | basis, and the Zsh Development Group have no obligation to provide 37 | maintenance, support, updates, enhancements, or modifications. 38 | -------------------------------------------------------------------------------- /.github/README.md: -------------------------------------------------------------------------------- 1 | # ZPMOD 2 | 3 |
4 | 5 | [![🍎 Build (MacOS)](https://github.com/z-shell/zpmod/actions/workflows/test-macos.yml/badge.svg)](https://github.com/z-shell/zpmod/actions/workflows/test-macos.yml) 6 | [![🐧 Build (Linux)](https://github.com/z-shell/zpmod/actions/workflows/test-linux.yml/badge.svg)](https://github.com/z-shell/zpmod/actions/workflows/test-linux.yml) 7 | 8 |

9 | 10 | The module is a binary Zsh module (think about `zmodload` Zsh command, it's that topic) which transparently and automatically **compiles sourced scripts**. Many plugin managers do not offer compilation of plugins, the module is a solution to this. Even if a plugin manager does compile plugin's main script (like Zi does). 11 | 12 | ## Installation 13 | 14 | ### Without [Zi](https://github.com/z-shell/zi) 15 | 16 | #### Quick Install (Recommended) 17 | 18 | Install just the **standalone** binary which can be used with any other plugin manager. 19 | 20 | > **Note** 21 | > This script can be used with most plugin managers and [Zi](https://github.com/z-shell/zi) is not required. 22 | 23 | ```sh 24 | sh <(curl -fsSL https://raw.githubusercontent.com/z-shell/zpmod/main/Scripts/install.sh) 25 | ``` 26 | 27 | This script will display what to add to `~/.zshrc` (2 lines) and show usage instructions. 28 | 29 | #### Manual Install with Advanced Options 30 | 31 | You can also clone the repository and use the included build.sh script with various configuration options: 32 | 33 | ```sh 34 | git clone https://github.com/z-shell/zpmod.git 35 | cd zpmod 36 | ./build.sh [OPTIONS] 37 | ``` 38 | 39 | The build script supports these options: 40 | 41 | | Option | Description | 42 | | ------------------------------ | ----------------------------------------------------------------- | 43 | | `--target=DIR`, `--target DIR` | Install to a specific directory | 44 | | `--clean` | Run `make distclean` instead of `make clean` | 45 | | `--quiet`, `-q` | Suppress non-essential output | 46 | | `--verbose`, `-v` | Show more detailed build information | 47 | | `--no-git` | Skip git clone/pull operations | 48 | | `--force`, `-f` | Force rebuild even if Makefile exists | 49 | | `--build-only` | Build but don't update .zshrc | 50 | | `--cflags="..."` | Pass custom CFLAGS to configure (default: `-g -Wall -Wextra -O3`) | 51 | | `--branch=NAME` | Use specific git branch (default: main) | 52 | | `--zsh-path=PATH` | Use specific Zsh executable | 53 | | `--jobs=N`, `-jN` | Set number of parallel make jobs | 54 | | `--prefix=DIR` | Set installation prefix (for system installs) | 55 | | `--no-install` | Skip installation after building | 56 | | `--help`, `-h` | Show help message | 57 | 58 | #### Examples 59 | 60 | ```sh 61 | # Install to a custom directory 62 | ./build.sh --target=/opt/zsh-modules/zpmod 63 | 64 | # Build with specific compiler optimizations 65 | ./build.sh --cflags="-O3 -march=native" 66 | 67 | # System installation 68 | sudo ./build.sh --prefix=/usr/local 69 | 70 | # Quiet installation with 8 parallel jobs 71 | ./build.sh --quiet --jobs=8 72 | 73 | # Development build from a specific branch 74 | ./build.sh --branch=develop --verbose 75 | ``` 76 | 77 | ### With [Zi](https://github.com/z-shell/zi) 78 | 79 | > **Note** 80 | > Zi users can build the module by issuing the following command instead of running the above installation scripts. 81 | 82 | ```shell 83 | zi module build 84 | ``` 85 | 86 | This command will compile the module and display instructions on what to add to `~/.zshrc`. 87 | 88 | ## Loading the Module 89 | 90 | After installation, add these lines at the top of your `~/.zshrc`: 91 | 92 | ```zsh 93 | # Adjust the path if you installed to a custom location 94 | module_path+=( "${HOME}/.zi/zmodules/zpmod/Src" ) 95 | zmodload zi/zpmod 96 | ``` 97 | 98 | ## Measuring Time of Sources 99 | 100 | Besides the compilation-feature, the module also measures **duration** of each script sourcing. 101 | Issue `zpmod source-study` after loading the module at top of `~/.zshrc` to see a list of all sourced files with the time the 102 | sourcing took in milliseconds on the left. 103 | This feature allows you to profile the shell startup. Also, no script can pass through that check and you will obtain a complete list of all loaded scripts, 104 | like if Zshell itself was investigating this. The list can be surprising. 105 | 106 | ## Debugging 107 | 108 | To enable debug messages from the module set: 109 | 110 | ```shell 111 | typeset -g ZI_MOD_DEBUG=1 112 | ``` 113 | 114 | ## System Requirements 115 | 116 | - Zsh version 5.8.1 or newer 117 | - GCC or compatible compiler 118 | - Make 119 | - Git (optional, can be skipped with `--no-git`) 120 | 121 | ## Troubleshooting 122 | 123 | If you encounter build issues: 124 | 125 | 1. Use `--verbose` to see detailed build output 126 | 2. Check the `make.log` file in the build directory 127 | 3. Make sure your Zsh version is compatible (5.8.1+) 128 | 4. Try with `--clean` to perform a fresh build 129 | 5. Submit an issue with the error messages on the [GitHub repository](https://github.com/z-shell/zpmod/issues) 130 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/test-linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐧 Build (Linux) 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | shellcheck: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: ⤵️ Check out code from GitHub 22 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 23 | - name: ☑️ ShellCheck 24 | uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 25 | with: 26 | scandir: "./Scripts/install.sh" 27 | 28 | build: 29 | runs-on: ubuntu-latest 30 | timeout-minutes: 30 31 | needs: [shellcheck] 32 | steps: 33 | - name: ⤵️ Check out code from GitHub 34 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 35 | - name: ⚙️ Prepare 36 | run: | 37 | sudo apt-get update 38 | sudo apt-get install -y zsh 39 | - name: ⚙️ Determine Branch 40 | id: branch 41 | env: 42 | HEAD_REF: ${{ github.head_ref }} 43 | REF_NAME: ${{ github.ref_name }} 44 | EVENT_NAME: ${{ github.event_name }} 45 | run: | 46 | # For PR events, use HEAD_REF; for push events, use REF_NAME 47 | if [ "$EVENT_NAME" = "pull_request" ]; then 48 | echo "branch=$HEAD_REF" >> $GITHUB_OUTPUT 49 | else 50 | echo "branch=$REF_NAME" >> $GITHUB_OUTPUT 51 | fi 52 | - name: ⚙️ Build 53 | env: 54 | BRANCH_NAME: ${{ steps.branch.outputs.branch }} 55 | run: | 56 | sh ./Scripts/install.sh --no-git --target=$(pwd) --branch="$BRANCH_NAME" 57 | ls -la ./Src/zi 58 | - name: ⚙️ Load 59 | run: | 60 | module_path+=( "$PWD/Src" ) 61 | zmodload zi/zpmod 62 | zpmod source-study -l 63 | shell: zsh {0} 64 | -------------------------------------------------------------------------------- /.github/workflows/test-macos.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🍎 Build (MacOS) 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | shellcheck: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: ⤵️ Check out code from GitHub 22 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 23 | - name: ☑️ ShellCheck 24 | uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 25 | with: 26 | scandir: "./Scripts/install.sh" 27 | 28 | build: 29 | runs-on: macos-latest 30 | timeout-minutes: 30 31 | needs: [shellcheck] 32 | steps: 33 | - name: ⤵️ Check out code from GitHub 34 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 35 | - name: ⚙️ Determine Branch 36 | id: branch 37 | env: 38 | HEAD_REF: ${{ github.head_ref }} 39 | REF_NAME: ${{ github.ref_name }} 40 | EVENT_NAME: ${{ github.event_name }} 41 | run: | 42 | # For PR events, use HEAD_REF; for push events, use REF_NAME 43 | if [ "$EVENT_NAME" = "pull_request" ]; then 44 | echo "branch=$HEAD_REF" >> $GITHUB_OUTPUT 45 | else 46 | echo "branch=$REF_NAME" >> $GITHUB_OUTPUT 47 | fi 48 | - name: ⚙️ Prepare 49 | run: | 50 | brew install zsh 51 | - name: ⚙️ Build 52 | env: 53 | BRANCH_NAME: ${{ steps.branch.outputs.branch }} 54 | run: | 55 | # Use --no-git to prevent cloning and use the checked out code 56 | # Use --target to build in the current directory 57 | sh ./Scripts/install.sh --no-git --target=$(pwd) --branch="$BRANCH_NAME" 58 | ls -la ./Src/zi 59 | - name: ⚙️ Load 60 | run: | 61 | module_path+=( "$PWD/Src" ) 62 | zmodload zi/zpmod 63 | zpmod source-study -l 64 | shell: zsh {0} 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | tags 3 | TAGS 4 | COMPILED_AT 5 | *.o 6 | *.o.c 7 | *.orig 8 | *.a 9 | *.so 10 | *.dll 11 | *.log 12 | *.bundle 13 | *~ 14 | .*.sw? 15 | \#* 16 | 17 | /META-FAQ 18 | /config.cache 19 | /config.h 20 | /config.log 21 | /config.modules 22 | /config.modules.sh 23 | /config.status 24 | /config.status.lineno 25 | /cscope.out 26 | /stamp-h 27 | /autom4te.cache 28 | 29 | Config/defs.mk 30 | 31 | CVS 32 | .#* 33 | 34 | Doc/help 35 | Doc/help.txt 36 | Doc/help/[_a-zA-Z0-9]* 37 | 38 | Doc/intro.pdf 39 | Doc/intro.ps 40 | Doc/intro.a4.pdf 41 | Doc/intro.a4.ps 42 | Doc/intro.us.pdf 43 | Doc/intro.us.ps 44 | Doc/version.yo 45 | Doc/texi2html.conf 46 | Doc/zsh*.1 47 | Doc/zsh.texi 48 | Doc/zsh.info* 49 | Doc/*.html 50 | Doc/zsh.aux 51 | Doc/zsh.toc 52 | Doc/zsh.cp 53 | Doc/zsh.cps 54 | Doc/zsh.fn 55 | Doc/zsh.fns 56 | Doc/zsh.ky 57 | Doc/zsh.kys 58 | Doc/zsh.pg 59 | Doc/zsh.pgs 60 | Doc/zsh.vr 61 | Doc/zsh.vrs 62 | Doc/zsh.log 63 | Doc/zsh.dvi 64 | Doc/zsh_a4.dvi 65 | Doc/zsh_us.dvi 66 | Doc/zsh.tp 67 | Doc/zsh.tps 68 | Doc/zsh.idx 69 | Doc/zsh_*.ps 70 | Doc/infodir 71 | Doc/zsh.pdf 72 | Doc/zsh_a4.pdf 73 | Doc/zsh_us.pdf 74 | 75 | Doc/Zsh/modlist.yo 76 | Doc/Zsh/modmenu.yo 77 | Doc/Zsh/manmodmenu.yo 78 | 79 | Etc/FAQ 80 | Etc/FAQ.html 81 | 82 | Src/*.epro 83 | Src/*.export 84 | Src/*.mdh 85 | Src/*.mdh.tmp 86 | Src/*.mdhi 87 | Src/*.mdhs 88 | Src/*.syms 89 | Src/Makemod.in 90 | Src/Makemod 91 | Src/[_a-zA-Z0-9]*.pro 92 | Src/ansi2knr 93 | Src/bltinmods.list 94 | Src/cscope.out 95 | Src/libzsh.so* 96 | Src/modules-bltin 97 | Src/modules.index 98 | Src/modules.index.tmp 99 | Src/modules.stamp 100 | Src/patchlevel.h 101 | Src/sigcount.h 102 | Src/signames.c 103 | Src/signames2.c 104 | Src/stamp-modobjs 105 | Src/stamp-modobjs.tmp 106 | Src/tags 107 | Src/TAGS 108 | Src/version.h 109 | Src/zsh 110 | Src/zsh.exe 111 | Src/zshcurses.h 112 | Src/zshpaths.h 113 | Src/zshterm.h 114 | Src/zshxmods.h 115 | 116 | Src/Builtins/Makefile.in 117 | Src/Builtins/*.export 118 | Src/Builtins/so_locations 119 | Src/Builtins/*.pro 120 | Src/Builtins/*.epro 121 | Src/Builtins/*.syms 122 | Src/Builtins/*.mdh 123 | Src/Builtins/*.mdhi 124 | Src/Builtins/*.mdhs 125 | Src/Builtins/*.mdh.tmp 126 | Src/Builtins/rlimits.h 127 | 128 | Src/Modules/Makefile.in 129 | Src/Modules/*.export 130 | Src/Modules/so_locations 131 | Src/Modules/*.pro 132 | Src/Modules/*.epro 133 | Src/Modules/*.syms 134 | Src/Modules/*.mdh 135 | Src/Modules/*.mdhi 136 | Src/Modules/*.mdhs 137 | Src/Modules/*.mdh.tmp 138 | Src/Modules/errnames.c 139 | Src/Modules/errcount.h 140 | Src/Modules/curses_keys.h 141 | 142 | Src/Zle/Makefile.in 143 | Src/Zle/*.export 144 | Src/Zle/so_locations 145 | Src/Zle/*.pro 146 | Src/Zle/*.epro 147 | Src/Zle/*.syms 148 | Src/Zle/*.mdh 149 | Src/Zle/*.mdhi 150 | Src/Zle/*.mdhs 151 | Src/Zle/*.mdh.tmp 152 | Src/Zle/thingies.list 153 | Src/Zle/widgets.list 154 | Src/Zle/zle_things.h 155 | Src/Zle/zle_widget.h 156 | 157 | Src/zi/Makefile.in 158 | Src/zi/zpmod.epro 159 | Src/zi/zpmod.export 160 | Src/zi/zpmod.mdh 161 | Src/zi/zpmod.mdhi 162 | Src/zi/zpmod.mdhs 163 | Src/zi/zpmod.pro 164 | Src/zi/zpmod.syms 165 | 166 | Test/*.tmp 167 | /.project 168 | -------------------------------------------------------------------------------- /.preconfig: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | autoconf 6 | autoheader 7 | echo >stamp-h.in 8 | -------------------------------------------------------------------------------- /.trunk/.gitignore: -------------------------------------------------------------------------------- 1 | *out 2 | *logs 3 | *actions 4 | *notifications 5 | *tools 6 | plugins 7 | user_trunk.yaml 8 | user.yaml 9 | tmp 10 | -------------------------------------------------------------------------------- /.trunk/configs/.markdownlint.yaml: -------------------------------------------------------------------------------- 1 | # Autoformatter friendly markdownlint config (all formatting rules disabled) 2 | default: true 3 | blank_lines: false 4 | bullet: false 5 | html: false 6 | indentation: false 7 | line_length: false 8 | spaces: false 9 | url: false 10 | whitespace: false 11 | -------------------------------------------------------------------------------- /.trunk/configs/.shellcheckrc: -------------------------------------------------------------------------------- 1 | enable=all 2 | source-path=SCRIPTDIR 3 | disable=SC2154 4 | 5 | # If you're having issues with shellcheck following source, disable the errors via: 6 | # disable=SC1090 7 | # disable=SC1091 8 | -------------------------------------------------------------------------------- /.trunk/configs/.yamllint.yaml: -------------------------------------------------------------------------------- 1 | rules: 2 | quoted-strings: 3 | required: only-when-needed 4 | extra-allowed: ["{|}"] 5 | key-duplicates: {} 6 | octal-values: 7 | forbid-implicit-octal: true 8 | -------------------------------------------------------------------------------- /.trunk/trunk.yaml: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | cli: 3 | version: 1.24.0 4 | plugins: 5 | sources: 6 | - id: trunk 7 | ref: v1.7.0 8 | uri: https://github.com/trunk-io/plugins 9 | lint: 10 | disabled: 11 | - yamllint 12 | - checkov 13 | - trufflehog 14 | enabled: 15 | - gitleaks@8.26.0 16 | - prettier@3.5.3 17 | - actionlint@1.7.7 18 | - markdownlint@0.45.0 19 | - git-diff-check 20 | - shfmt@3.6.0 21 | - shellcheck@0.10.0 22 | ignore: 23 | - linters: [ALL] 24 | paths: 25 | - "Src/*" 26 | - "Test/*" 27 | - "Config/*" 28 | - "config*" 29 | - "configure*" 30 | - "install-sh" 31 | - "mkinstalldirs" 32 | runtimes: 33 | enabled: 34 | - python@3.10.8 35 | - go@1.21.0 36 | - node@22.16.0 37 | actions: 38 | enabled: 39 | - trunk-announce 40 | - trunk-check-pre-push 41 | - trunk-fmt-pre-commit 42 | - trunk-upgrade-available 43 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "enabled" 3 | } 4 | -------------------------------------------------------------------------------- /Config/.cvsignore: -------------------------------------------------------------------------------- 1 | defs.mk 2 | *.swp 3 | -------------------------------------------------------------------------------- /Config/.distfiles: -------------------------------------------------------------------------------- 1 | DISTFILES_SRC=' 2 | ' 3 | -------------------------------------------------------------------------------- /Config/aczshoot.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([zsh_OOT], 2 | [ 3 | AC_CHECK_HEADERS(stdarg.h varargs.h termios.h termio.h) 4 | AC_TYPE_SIGNAL 5 | AC_DEFINE([ZSH_OOT_MODULE], [], [Out-of-tree module]) 6 | ]) 7 | -------------------------------------------------------------------------------- /Config/clean.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile fragment for cleanup 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | mostlyclean: mostlyclean-recursive mostlyclean-here 28 | clean: clean-recursive clean-here 29 | distclean: distclean-recursive distclean-here 30 | realclean: realclean-recursive realclean-here 31 | 32 | mostlyclean-here: 33 | clean-here: mostlyclean-here 34 | distclean-here: clean-here 35 | realclean-here: distclean-here 36 | 37 | mostlyclean-recursive clean-recursive distclean-recursive realclean-recursive: 38 | @subdirs='$(SUBDIRS)'; if test -n "$$subdirs"; then \ 39 | target=`echo $@ | sed s/-recursive//`; \ 40 | for subdir in $$subdirs; do \ 41 | (cd $$subdir && $(MAKE) $(MAKEDEFS) $$target) || exit 1; \ 42 | done; \ 43 | fi 44 | -------------------------------------------------------------------------------- /Config/config.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile fragment for building Makefiles 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | config: Makefile 28 | @subdirs='$(SUBDIRS)'; for subdir in $$subdirs; do \ 29 | (cd $$subdir && $(MAKE) $(MAKEDEFS) $@) || exit 1; \ 30 | done 31 | 32 | CONFIG_INCS = \ 33 | $(dir_top)/Config/clean.mk $(dir_top)/Config/config.mk \ 34 | $(dir_top)/Config/defs.mk $(dir_top)/Config/version.mk 35 | 36 | Makefile: Makefile.in $(dir_top)/config.status $(CONFIG_INCS) 37 | cd $(dir_top) && \ 38 | $(SHELL) ./config.status `echo $(subdir)/$@ | sed 's%^./%%'` 39 | 40 | $(dir_top)/Config/defs.mk: $(sdir_top)/Config/defs.mk.in $(dir_top)/config.status 41 | cd $(dir_top) && \ 42 | $(SHELL) ./config.status Config/defs.mk 43 | -------------------------------------------------------------------------------- /Config/defs.mk.in: -------------------------------------------------------------------------------- 1 | # 2 | # Basic Makefile definitions 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | # fundamentals 28 | SHELL = /bin/sh 29 | @SET_MAKE@ 30 | EXEEXT = @EXEEXT@ 31 | 32 | # headers 33 | ZSH_CURSES_H = @ZSH_CURSES_H@ 34 | ZSH_TERM_H = @ZSH_TERM_H@ 35 | 36 | # install basename 37 | tzsh = @tzsh@ 38 | 39 | # installation directories 40 | prefix = @prefix@ 41 | exec_prefix = @exec_prefix@ 42 | bindir = @bindir@ 43 | libdir = @libdir@ 44 | MODDIR = $(libdir)/$(tzsh)/$(VERSION) 45 | infodir = @infodir@ 46 | mandir = @mandir@ 47 | datarootdir = @datarootdir@ 48 | datadir = @datadir@ 49 | fndir = @fndir@ 50 | fixed_sitefndir = @fixed_sitefndir@ 51 | sitefndir = @sitefndir@ 52 | scriptdir = @scriptdir@ 53 | sitescriptdir = @sitescriptdir@ 54 | htmldir = @htmldir@ 55 | runhelpdir = @runhelpdir@ 56 | runhelp = @runhelp@ 57 | 58 | # compilation 59 | CC = @CC@ 60 | CPP = @CPP@ 61 | CPPFLAGS = @CPPFLAGS@ 62 | DEFS = @DEFS@ 63 | CFLAGS = @CFLAGS@ 64 | LDFLAGS = @LDFLAGS@ 65 | EXTRA_LDFLAGS = @EXTRA_LDFLAGS@ 66 | DLCFLAGS = @DLCFLAGS@ 67 | DLLDFLAGS = @DLLDFLAGS@ 68 | LIBLDFLAGS = @LIBLDFLAGS@ 69 | EXELDFLAGS = @EXELDFLAGS@ 70 | LIBS = @LIBS@ 71 | DL_EXT = @DL_EXT@ 72 | DLLD = @DLLD@ 73 | EXPOPT = @EXPOPT@ 74 | IMPOPT = @IMPOPT@ 75 | 76 | # utilities 77 | AWK = @AWK@ 78 | ANSI2KNR = @ANSI2KNR@ 79 | YODL = @YODL@ @YODL_OPTIONS@ 80 | YODL2TXT = @YODL@2txt 81 | YODL2HTML = @YODL@2html 82 | 83 | # install utility 84 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 85 | INSTALL_DATA = @INSTALL_DATA@ 86 | 87 | # variables used in determining what to install 88 | FUNCTIONS_SUBDIRS = @FUNCTIONS_SUBDIRS@ 89 | 90 | # Additional fpath entries (eg. for vendor specific directories). 91 | additionalfpath = @additionalfpath@ 92 | 93 | # flags passed to recursive makes in subdirectories 94 | MAKEDEFS = \ 95 | prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \ 96 | libdir='$(libdir)' MODDIR='$(MODDIR)' infodir='$(infodir)' mandir='$(mandir)' \ 97 | datadir='$(datadir)' fndir='$(fndir)' htmldir='$(htmldir)' runhelpdir='$(runhelpdir)' \ 98 | CC='$(CC)' CPPFLAGS='$(CPPFLAGS)' DEFS='$(DEFS)' CFLAGS='$(CFLAGS)' \ 99 | LDFLAGS='$(LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ 100 | DLCFLAGS='$(DLCFLAGS)' DLLDFLAGS='$(DLLDFLAGS)' \ 101 | LIBLDFLAGS='$(LIBLDFLAGS)' EXELDFLAGS='$(EXELDFLAGS)' \ 102 | LIBS='$(LIBS)' DL_EXT='$(DL_EXT)' DLLD='$(DLLD)' \ 103 | AWK='$(AWK)' ANSI2KNR='$(ANSI2KNR)' \ 104 | YODL='$(YODL)' YODL2TXT='$(YODL2TXT)' YODL2HTML='$(YODL2HTML)' \ 105 | FUNCTIONS_INSTALL='$(FUNCTIONS_INSTALL)' tzsh='$(tzsh)' 106 | 107 | # override built-in suffix list 108 | .SUFFIXES: 109 | 110 | # parallel build is not supported (pmake, gmake) 111 | .NOTPARALLEL: 112 | 113 | # parallel build is not supported (dmake) 114 | .NO_PARALLEL: 115 | -------------------------------------------------------------------------------- /Config/installfns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | fndir=$DESTDIR$fndir 4 | scriptdir=$DESTDIR$scriptdir 5 | 6 | /bin/sh $sdir_top/mkinstalldirs $fndir || exit 1; 7 | 8 | allfuncs="`grep ' functions=.' ${dir_top}/config.modules | 9 | sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`" 10 | 11 | allfuncs="`cd $sdir_top; echo ${allfuncs}`" 12 | 13 | test -d installfnsdir || mkdir installfnsdir 14 | 15 | # We now have a list of files, but we need to use `test -f' to check 16 | # (1) the glob got expanded (2) we are not looking at directories. 17 | for file in $allfuncs; do 18 | if test -f $sdir_top/$file; then 19 | case "$file" in 20 | */CVS/*) continue;; 21 | esac 22 | if test x$FUNCTIONS_SUBDIRS != x && test x$FUNCTIONS_SUBDIRS != xno; then 23 | case "$file" in 24 | Completion/*/*) 25 | subdir="`echo $file | sed -e 's%/[^/]*/[^/]*$%%'`" 26 | instdir="$fndir/$subdir" 27 | ;; 28 | Completion/*) 29 | instdir="$fndir/Completion" 30 | ;; 31 | Scripts/*) 32 | instdir="$scriptdir" 33 | ;; 34 | *) 35 | subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`" 36 | instdir="$fndir/$subdir" 37 | ;; 38 | esac 39 | else 40 | case "$file" in 41 | Scripts/*) 42 | instdir="$scriptdir" 43 | ;; 44 | *) 45 | instdir="$fndir" 46 | ;; 47 | esac 48 | fi 49 | basename=`basename $file` 50 | ok=0 51 | if test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir; then 52 | if sed "s|@runhelpdir@|$runhelpdir|" <$sdir_top/$file \ 53 | >installfnsdir/$basename; then 54 | if $INSTALL_DATA installfnsdir/$basename $instdir; then 55 | ok=1 56 | fi 57 | fi 58 | fi 59 | case $ok in 60 | 0) 61 | rm -rf installfnsdir 62 | exit 1 63 | ;; 64 | esac 65 | read line < $sdir_top/$file 66 | case "$line" in 67 | '#!'*) 68 | chmod +x $instdir/`echo $file | sed -e 's%^.*/%%'` 69 | ;; 70 | esac 71 | fi 72 | done 73 | 74 | rm -rf installfnsdir 75 | -------------------------------------------------------------------------------- /Config/uninstallfns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | fndir=$DESTDIR$fndir 4 | scriptdir=$DESTDIR$scriptdir 5 | 6 | allfuncs="`grep ' functions=' ${dir_top}/config.modules | 7 | sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`" 8 | 9 | allfuncs="`cd ${sdir_top}; echo ${allfuncs}`" 10 | 11 | case $fndir in 12 | *$VERSION*) 13 | # Version specific function directory, safe to remove completely. 14 | rm -rf $fndir 15 | ;; 16 | *) # The following will only apply with a custom install directory 17 | # with no version information. This is rather undesirable. 18 | # But let's try and do the best we can. 19 | # We now have a list of files, but we need to use `test -f' to check 20 | # (1) the glob got expanded (2) we are not looking at directories. 21 | for file in $allfuncs; do 22 | case $file in 23 | Scripts/*) 24 | ;; 25 | *) 26 | if test -f $sdir_top/$file; then 27 | if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then 28 | file=`echo $file | sed -e 's%%^(Functions|Completion)/%'` 29 | rm -f $fndir/$file 30 | else 31 | bfile="`echo $file | sed -e 's%^.*/%%'`" 32 | rm -f "$fndir/$bfile" 33 | fi 34 | fi 35 | ;; 36 | esac 37 | done 38 | ;; 39 | esac 40 | 41 | case $scriptdir in 42 | *$VERSION*) 43 | # $scriptdir might be the parent of fndir. 44 | rm -rf $scriptdir 45 | ;; 46 | *) for file in $allfuncs; do 47 | case $file in 48 | Scripts/*) 49 | if test -f $sdir_top/$file; then 50 | bfile="`echo $file | sed -e 's%^.*/%%'`" 51 | rm -f "$scriptdir/$bfile" 52 | fi 53 | ;; 54 | esac 55 | done 56 | ;; 57 | esac 58 | 59 | exit 0 60 | -------------------------------------------------------------------------------- /Config/version.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile fragment for version numbers 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | # This must also serve as a shell script, so do not add spaces around the 28 | # `=' signs. 29 | 30 | VERSION=5.9.0.1-dev 31 | VERSION_DATE='May 15, 2022' 32 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for top level of zsh distribution 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | subdir = . 28 | dir_top = . 29 | SUBDIRS = Src 30 | 31 | @VERSION_MK@ 32 | 33 | # source/build directories 34 | VPATH = @srcdir@ 35 | sdir = @srcdir@ 36 | sdir_top = @top_srcdir@ 37 | INSTALL = @INSTALL@ 38 | 39 | @DEFS_MK@ 40 | 41 | # ========== DEPENDENCIES FOR BUILDING ========== 42 | 43 | # default target 44 | all: config.h config.modules 45 | cd Src && $(MAKE) $(MAKEDEFS) $@ 46 | 47 | # prepare module configuration 48 | prep: 49 | @cd Src && $(MAKE) $(MAKEDEFS) $@ 50 | 51 | # ========== DEPENDENCIES FOR CLEANUP ========== 52 | 53 | @CLEAN_MK@ 54 | 55 | distclean-here: 56 | rm -f Makefile config.h config.status config.log config.cache config.modules config.modules.sh stamp-h Config/defs.mk 57 | rm -rf autom4te.cache 58 | 59 | realclean-here: 60 | cd $(sdir) && rm -f config.h.in stamp-h.in configure 61 | 62 | # ========== DEPENDENCIES FOR MAINTENANCE ========== 63 | 64 | @CONFIG_MK@ 65 | 66 | config: config.h 67 | 68 | config.status: $(sdir)/configure 69 | $(SHELL) ./config.status --recheck 70 | 71 | $(sdir)/configure: $(sdir)/aclocal.m4 $(sdir)/aczsh.m4 $(sdir)/configure.ac 72 | cd $(sdir) && autoconf 73 | 74 | config.h: stamp-h 75 | stamp-h: $(sdir)/config.h.in config.status 76 | cd $(dir_top) && $(SHELL) ./config.status config.h $@ 77 | 78 | config.modules: $(sdir)/config.h.in config.status config.modules.sh 79 | cd $(dir_top) && $(SHELL) ./config.status $@ && \ 80 | $(SHELL) ./config.modules.sh 81 | 82 | $(sdir)/config.h.in: $(sdir)/stamp-h.in 83 | $(sdir)/stamp-h.in: $(sdir)/configure 84 | cd $(sdir) && autoheader 85 | echo > $(sdir)/stamp-h.in 86 | 87 | FORCE: 88 | -------------------------------------------------------------------------------- /RECOMPILE_REQUEST: -------------------------------------------------------------------------------- 1 | 1580588806 2 | -------------------------------------------------------------------------------- /Scripts/copy_from_zsh_src.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | [[ -z "$1" || "$1" = "-h" || "$1" = "--help" ]] && { print "Single argument: path to Zsh source tree"; exit 0; } 4 | 5 | print "Will invoke git clean -dxf, 3 seconds" 6 | sleep 3 7 | 8 | git clean -dxf 9 | 10 | [[ ! -d "$1" ]] && { print "Path to Zsh source doesn't exist (i.e.: $1)"; exit 1; } 11 | 12 | local from="$1" 13 | 14 | autoload -Uz colors 15 | colors 16 | 17 | integer count=0 18 | 19 | for i in configure.ac Src/*.c Src/*.h; do 20 | if [[ -f "$from/$i" ]]; then 21 | cp -vf "$from/$i" "$i" && (( ++ count )) || print "${fg_bold[red]}Copy error for: $i${reset_color}" 22 | else 23 | print "${fg[red]}$i Doesn't exist${reset_color}" 24 | fi 25 | done 26 | 27 | echo "${fg[green]}Copied ${fg[yellow]}$count${fg[green]} files${reset_color}" 28 | 29 | patch -p2 -i ./patch_cfgac.diff 30 | -------------------------------------------------------------------------------- /Src/.cvsignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.epro 3 | *.export 4 | *.mdh 5 | *.mdh.tmp 6 | *.mdhi 7 | *.mdhs 8 | *.o 9 | *.o.c 10 | *.so 11 | *.swp 12 | *.syms 13 | Makefile 14 | Makemod.in Makemod 15 | [_a-zA-Z0-9]*.pro 16 | ansi2knr 17 | bltinmods.list 18 | cscope.out 19 | libzsh.so* 20 | modules-bltin 21 | modules.index 22 | modules.index.tmp 23 | modules.stamp 24 | patchlevel.h 25 | sigcount.h 26 | signames.c signames2.c 27 | stamp-modobjs 28 | stamp-modobjs.tmp 29 | tags TAGS 30 | version.h 31 | zsh 32 | zshcurses.h 33 | zshpaths.h 34 | zshterm.h 35 | zshxmods.h 36 | -------------------------------------------------------------------------------- /Src/.distfiles: -------------------------------------------------------------------------------- 1 | DISTFILES_SRC=' 2 | ' 3 | -------------------------------------------------------------------------------- /Src/.exrc: -------------------------------------------------------------------------------- 1 | set ai 2 | set sw=4 3 | -------------------------------------------------------------------------------- /Src/.indent.pro: -------------------------------------------------------------------------------- 1 | --dont-format-comments 2 | --procnames-start-lines 3 | --no-parameter-indentation 4 | --indent-level4 5 | --line-comments-indentation4 6 | --cuddle-else 7 | --brace-indent0 8 | --dont-star-comments 9 | --blank-lines-after-declarations 10 | --blank-lines-after-procedures 11 | --no-blank-lines-after-commas 12 | --comment-indentation33 13 | --declaration-comment-column33 14 | --no-comment-delimiters-on-blank-lines 15 | --continuation-indentation4 16 | --case-indentation0 17 | --else-endif-column33 18 | --no-space-after-casts 19 | --no-blank-before-sizeof 20 | --declaration-indentation0 21 | --continue-at-parentheses 22 | --no-space-after-function-call-names 23 | --swallow-optional-blank-lines 24 | --dont-space-special-semicolon 25 | --tab-size8 26 | --line-length132 27 | --braces-on-if-line 28 | -------------------------------------------------------------------------------- /Src/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Src subdirectory 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | subdir = Src 28 | dir_top = .. 29 | SUBDIRS = 30 | 31 | @VERSION_MK@ 32 | 33 | # source/build directories 34 | VPATH = @srcdir@ 35 | sdir = @srcdir@ 36 | sdir_top = @top_srcdir@ 37 | INSTALL = @INSTALL@ 38 | LN = @LN@ 39 | 40 | @DEFS_MK@ 41 | 42 | sdir_src = $(sdir) 43 | dir_src = . 44 | 45 | # ========= DEPENDENCIES FOR BUILDING ========== 46 | 47 | LINK = $(CC) $(LDFLAGS) $(EXELDFLAGS) $(EXTRA_LDFLAGS) -o $@ 48 | DLLINK = $(DLLD) $(LDFLAGS) $(LIBLDFLAGS) $(DLLDFLAGS) -o $@ 49 | 50 | all: zsh.export modules 51 | .PHONY: all 52 | 53 | modules: headers 54 | .PHONY: modules 55 | 56 | L = @L@ 57 | 58 | LSTMP = 59 | LLIST = 60 | NSTMP = stamp-modobjs 61 | NLIST = `cat stamp-modobjs` 62 | 63 | LIBZSH = libzsh-$(VERSION).$(DL_EXT) 64 | NIBZSH = 65 | INSTLIB = @INSTLIB@ 66 | UNINSTLIB = @UNINSTLIB@ 67 | 68 | ZSH_EXPORT = $(EXPOPT)zsh.export 69 | ZSH_NXPORT = 70 | ENTRYOBJ = modentry..o 71 | NNTRYOBJ = 72 | 73 | LDRUNPATH = LD_RUN_PATH=$(libdir)/$(tzsh) 74 | NDRUNPATH = 75 | 76 | EXTRAZSHOBJS = @EXTRAZSHOBJS@ 77 | 78 | stamp-modobjs: modobjs 79 | @if cmp -s stamp-modobjs.tmp stamp-modobjs; then \ 80 | rm -f stamp-modobjs.tmp; \ 81 | echo "\`stamp-modobjs' is up to date."; \ 82 | else \ 83 | mv -f stamp-modobjs.tmp stamp-modobjs; \ 84 | echo "Updated \`stamp-modobjs'."; \ 85 | fi 86 | 87 | modobjs: headers rm-modobjs-tmp 88 | .PHONY: modobjs 89 | 90 | rm-modobjs-tmp: 91 | rm -f stamp-modobjs.tmp 92 | .PHONY: rm-modobjs-tmp 93 | 94 | @CONFIG_MK@ 95 | 96 | Makemod: $(CONFIG_INCS) $(dir_top)/config.modules 97 | @case $(sdir_top) in \ 98 | /*) top_srcdir=$(sdir_top) ;; \ 99 | *) top_srcdir=$(subdir)/$(sdir_top) ;; \ 100 | esac; \ 101 | export top_srcdir; \ 102 | echo 'cd $(dir_top) && $(SHELL)' \ 103 | '$$top_srcdir/$(subdir)/mkmakemod.sh $(subdir) Makemod'; \ 104 | cd $(dir_top) && \ 105 | $(SHELL) $$top_srcdir/$(subdir)/mkmakemod.sh $(subdir) Makemod 106 | prep: Makemod 107 | @$(MAKE) -f Makemod $(MAKEDEFS) prep || rm -f Makemod 108 | .PHONY: prep 109 | 110 | FORCE: 111 | .PHONY: FORCE 112 | 113 | # ========== LINKING IN MODULES ========== 114 | 115 | mymods.conf: 116 | @echo Linking with the standard modules. 117 | 118 | modules: $(@E@NTRYOBJ) 119 | 120 | $(ENTRYOBJ): FORCE 121 | @$(MAKE) -f Makemod $(MAKEDEFS) $@ 122 | 123 | # ========== DEPENDENCIES FOR CLEANUP ========== 124 | 125 | # Since module cleanup rules depend on Makemod, they come first. This 126 | # forces module stuff to get cleaned before Makemod itself gets 127 | # deleted. 128 | 129 | mostlyclean-here: 130 | rm -f stamp-modobjs stamp-modobjs.tmp 131 | .PHONY: mostlyclean-here 132 | 133 | clean-here: 134 | rm -f modules.stamp zsh$(EXEEXT) 135 | rm -f libzsh-*.$(DL_EXT) 136 | .PHONY: clean-here 137 | 138 | distclean-here: 139 | rm -f TAGS tags 140 | rm -f Makefile 141 | .PHONY: distclean-here 142 | 143 | mostlyclean: mostlyclean-modules 144 | clean: clean-modules 145 | distclean: distclean-modules 146 | realclean: realclean-modules 147 | .PHONY: mostlyclean clean distclean realclean 148 | 149 | # Don't remake Makemod just to delete things, even if it doesn't exist. 150 | mostlyclean-modules clean-modules distclean-modules realclean-modules: 151 | if test -f Makemod; then \ 152 | $(MAKE) -f Makemod $(MAKEDEFS) `echo $@ | sed 's/-modules//'`; \ 153 | fi; \ 154 | exit 0 155 | .PHONY: mostlyclean-modules clean-modules distclean-modules \ 156 | realclean-modules 157 | 158 | @CLEAN_MK@ 159 | 160 | # ========== RECURSIVE MAKES ========== 161 | 162 | modobjs modules headers proto zsh.export: Makemod 163 | @$(MAKE) -f Makemod $(MAKEDEFS) $@ 164 | .PHONY: headers proto 165 | -------------------------------------------------------------------------------- /Src/Makemod.in.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makemod.in.in 3 | # 4 | # Copyright (c) 1995-1997 Richard Coleman 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Richard Coleman or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Richard Coleman and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Richard Coleman and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Richard Coleman and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | # ========== OVERRIDABLE VARIABLES ========== 28 | 29 | # subdir is done by mkmakemod.sh 30 | # dir_top is done by mkmakemod.sh 31 | # SUBDIRS is done by mkmakemod.sh 32 | 33 | @VERSION_MK@ 34 | 35 | # source/build directories 36 | VPATH = @srcdir@ 37 | sdir = @srcdir@ 38 | sdir_top = @top_srcdir@ 39 | INSTALL = @INSTALL@ 40 | 41 | @DEFS_MK@ 42 | 43 | sdir_src = $(sdir_top)/Src 44 | dir_src = $(dir_top)/Src 45 | 46 | # ========== COMPILATION RULES ========== 47 | 48 | DNCFLAGS = 49 | 50 | COMPILE = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/Zle -I$(sdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(D@L@CFLAGS) 51 | DLCOMPILE = $(CC) -c -I. -I$(dir_top)/Src -I$(sdir_top)/Src -I$(sdir_top)/Src/Zle -I$(sdir) $(CPPFLAGS) $(DEFS) -DMODULE $(CFLAGS) $(DLCFLAGS) 52 | LINK = $(CC) $(LDFLAGS) $(EXELDFLAGS) $(EXTRA_LDFLAGS) -o $@ 53 | DLLINK = $(DLLD) $(LDFLAGS) $(LIBLDFLAGS) $(DLLDFLAGS) -o $@ 54 | 55 | KNR_OBJ=.o 56 | KNROBJ=._foo_ 57 | 58 | ANSIOBJ=.o 59 | ANSI_OBJ=._foo_ 60 | 61 | .SUFFIXES: .c .$(DL_EXT) ..o .._foo_ .o ._foo_ .syms .pro .epro 62 | 63 | .c$(ANSI@U@OBJ): 64 | $(COMPILE) -o $@ $< 65 | @rm -f $(dir_src)/stamp-modobjs 66 | 67 | .c$(KNR@U@OBJ): 68 | @ANSI2KNR@ $< > $@.c 69 | $(COMPILE) -o $@ $@.c 70 | rm -f $@.c 71 | @rm -f $(dir_src)/stamp-modobjs 72 | 73 | .c.$(ANSI@U@OBJ): 74 | $(DLCOMPILE) -o $@ $< 75 | 76 | .c.$(KNR@U@OBJ): 77 | @ANSI2KNR@ $< > $@.c 78 | $(DLCOMPILE) -o $@ $@.c 79 | rm -f $@.c 80 | 81 | .c.syms: 82 | $(AWK) -f $(sdir_src)/makepro.awk $< $(subdir) > $@ 83 | 84 | .syms.epro: 85 | (echo '/* Generated automatically */'; sed -n '/^E/{s/^E//;p;}' < $<) \ 86 | > $@ 87 | (echo '/* Generated automatically */'; sed -n '/^L/{s/^L//;p;}' < $<) \ 88 | > `echo $@ | sed 's/\.epro$$/.pro/'` 89 | 90 | PROTODEPS = $(sdir_src)/makepro.awk 91 | 92 | # ========== DEPENDENCIES FOR BUILDING ========== 93 | 94 | all: modobjs modules 95 | .PHONY: all 96 | 97 | modobjs: $(MODOBJS) 98 | modules: $(MODULES) 99 | headers: $(MDHS) 100 | proto: $(PROTOS) 101 | .PHONY: modobjs modules headers proto 102 | 103 | prep: 104 | @case $(sdir_top) in \ 105 | /*) top_srcdir=$(sdir_top) ;; \ 106 | *) top_srcdir=$(subdir)/$(sdir_top) ;; \ 107 | esac; \ 108 | export top_srcdir; \ 109 | cd $(dir_top) || exit 1; \ 110 | subdirs='$(SUBDIRS)'; \ 111 | for subdir in $$subdirs; do \ 112 | dir=$(subdir)/$$subdir; \ 113 | test -d $$dir || mkdir $$dir; \ 114 | $(SHELL) $$top_srcdir/Src/mkmakemod.sh $$dir Makefile || exit 1; \ 115 | ( cd $$dir && $(MAKE) $(MAKEDEFS) $@ ) || exit 1; \ 116 | done 117 | .PHONY: prep 118 | 119 | headers: $(dir_src)/modules.stamp 120 | $(dir_src)/modules.stamp: $(MDDS) 121 | $(MAKE) -f $(makefile) $(MAKEDEFS) prep 122 | echo 'timestamp for *.mdd files' > $@ 123 | .PHONY: headers 124 | 125 | FORCE: 126 | .PHONY: FORCE 127 | 128 | # ========== DEPENDENCIES FOR INSTALLING ========== 129 | 130 | install: install.bin install.modules 131 | uninstall: uninstall.bin uninstall.modules 132 | .PHONY: install uninstall 133 | 134 | install.bin: install.bin-here 135 | uninstall.bin: uninstall.bin-here 136 | install.modules: install.modules-here 137 | uninstall.modules: uninstall.modules-here 138 | .PHONY: install.bin uninstall.bin install.modules uninstall.modules 139 | 140 | install.bin-here uninstall.bin-here: 141 | install.modules-here uninstall.modules-here: 142 | .PHONY: install.bin-here install.modules-here 143 | 144 | # ========== DEPENDENCIES FOR CLEANUP ========== 145 | 146 | @CLEAN_MK@ 147 | 148 | mostlyclean-here: 149 | rm -f *.o *.export *.$(DL_EXT) 150 | .PHONY: mostlyclean-here 151 | 152 | clean-here: 153 | rm -f *.o.c *.syms *.pro *.epro *.mdh *.mdhi *.mdhs *.mdh.tmp 154 | .PHONY: clean-here 155 | 156 | distclean-here: 157 | rm -f $(makefile) $(makefile).in 158 | .PHONY: distclean-here 159 | 160 | # ========== RECURSIVE MAKES ========== 161 | 162 | install.bin uninstall.bin install.modules uninstall.modules \ 163 | modobjs modules headers proto: 164 | @subdirs='$(SUBDIRS)'; for subdir in $$subdirs; do \ 165 | ( cd $$subdir && $(MAKE) $(MAKEDEFS) $@ ) || exit 1; \ 166 | done 167 | 168 | # ========== DEPENDENCIES FOR MAINTENANCE ========== 169 | 170 | $(makefile): $(makefile).in $(dir_top)/config.status 171 | @case $(sdir_top) in \ 172 | /*) top_srcdir=$(sdir_top) ;; \ 173 | *) top_srcdir=$(subdir)/$(sdir_top) ;; \ 174 | esac; \ 175 | export top_srcdir; \ 176 | echo 'cd $(dir_top) && $(SHELL)' \ 177 | '$$top_srcdir/Src/mkmakemod.sh -m $(subdir) $(makefile)'; \ 178 | cd $(dir_top) && \ 179 | $(SHELL) $$top_srcdir/Src/mkmakemod.sh -m $(subdir) $(makefile) 180 | 181 | $(makefile).in: $(sdir_src)/mkmakemod.sh $(sdir_src)/Makemod.in.in $(MDDS) \ 182 | $(dir_top)/config.modules 183 | @case $(sdir_top) in \ 184 | /*) top_srcdir=$(sdir_top) ;; \ 185 | *) top_srcdir=$(subdir)/$(sdir_top) ;; \ 186 | esac; \ 187 | export top_srcdir; \ 188 | echo 'cd $(dir_top) && $(SHELL)' \ 189 | '$$top_srcdir/Src/mkmakemod.sh -i $(subdir) $(makefile)'; \ 190 | cd $(dir_top) && \ 191 | $(SHELL) $$top_srcdir/Src/mkmakemod.sh -i $(subdir) $(makefile) 192 | 193 | -------------------------------------------------------------------------------- /Src/hashtable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hashtable.h - header file for hash table handling code 3 | * 4 | * This file is part of zsh, the Z shell. 5 | * 6 | * Copyright (c) 1992-1997 Paul Falstad 7 | * All rights reserved. 8 | * 9 | * Permission is hereby granted, without written agreement and without 10 | * license or royalty fees, to use, copy, modify, and distribute this 11 | * software and to distribute modified versions of this software for any 12 | * purpose, provided that the above copyright notice and the following 13 | * two paragraphs appear in all copies of this software. 14 | * 15 | * In no event shall Paul Falstad or the Zsh Development Group be liable 16 | * to any party for direct, indirect, special, incidental, or consequential 17 | * damages arising out of the use of this software and its documentation, 18 | * even if Paul Falstad and the Zsh Development Group have been advised of 19 | * the possibility of such damage. 20 | * 21 | * Paul Falstad and the Zsh Development Group specifically disclaim any 22 | * warranties, including, but not limited to, the implied warranties of 23 | * merchantability and fitness for a particular purpose. The software 24 | * provided hereunder is on an "as is" basis, and Paul Falstad and the 25 | * Zsh Development Group have no obligation to provide maintenance, 26 | * support, updates, enhancements, or modifications. 27 | * 28 | */ 29 | 30 | /* Builtin function numbers; used by handler functions that handle more * 31 | * than one builtin. Note that builtins such as compctl, that are not * 32 | * overloaded, don't get a number. */ 33 | 34 | #define BIN_TYPESET 0 35 | #define BIN_BG 1 36 | #define BIN_FG 2 37 | #define BIN_JOBS 3 38 | #define BIN_WAIT 4 39 | #define BIN_DISOWN 5 40 | #define BIN_BREAK 6 41 | #define BIN_CONTINUE 7 42 | #define BIN_EXIT 8 43 | #define BIN_RETURN 9 44 | #define BIN_CD 10 45 | #define BIN_POPD 11 46 | #define BIN_PUSHD 12 47 | #define BIN_PRINT 13 48 | #define BIN_EVAL 14 49 | #define BIN_SCHED 15 50 | #define BIN_FC 16 51 | #define BIN_R 17 52 | #define BIN_PUSHLINE 18 53 | #define BIN_LOGOUT 19 54 | #define BIN_TEST 20 55 | #define BIN_BRACKET 21 56 | #define BIN_READONLY 22 57 | #define BIN_ECHO 23 58 | #define BIN_DISABLE 24 59 | #define BIN_ENABLE 25 60 | #define BIN_PRINTF 26 61 | #define BIN_COMMAND 27 62 | #define BIN_UNHASH 28 63 | #define BIN_UNALIAS 29 64 | #define BIN_UNFUNCTION 30 65 | #define BIN_UNSET 31 66 | #define BIN_EXPORT 32 67 | 68 | /* These currently depend on being 0 and 1. */ 69 | #define BIN_SETOPT 0 70 | #define BIN_UNSETOPT 1 71 | -------------------------------------------------------------------------------- /Src/makepro.awk: -------------------------------------------------------------------------------- 1 | # 2 | # makepro.awk - generate prototype lists 3 | # 4 | 5 | BEGIN { 6 | aborting = 0 7 | 8 | # arg 1 is the name of the file to process 9 | # arg 2 is the name of the subdirectory it is in 10 | if(ARGC != 3) { 11 | aborting = 1 12 | exit 1 13 | } 14 | name = ARGV[1] 15 | gsub(/^.*\//, "", name) 16 | gsub(/\.c$/, "", name) 17 | name = ARGV[2] "_" name 18 | gsub(/\//, "_", name) 19 | ARGC-- 20 | 21 | printf "E#ifndef have_%s_globals\n", name 22 | printf "E#define have_%s_globals\n", name 23 | printf "E\n" 24 | } 25 | 26 | # all relevant declarations are preceded by "/**/" on a line by itself 27 | 28 | /^\/\*\*\/$/ { 29 | # The declaration is on following lines. The interesting part might 30 | # be terminated by a `{' (`int foo(void) { }' or `int bar[] = {') 31 | # or `;' (`int x;'). 32 | line = "" 33 | isfunc = 0 34 | while(1) { 35 | if(getline <= 0) { 36 | aborting = 1 37 | exit 1 38 | } 39 | if (line == "" && $0 ~ /^[ \t]*#/) { 40 | # Directly after the /**/ was a preprocessor line. 41 | # Spit it out and re-start the outer loop. 42 | printf "E%s\n", $0 43 | printf "L%s\n", $0 44 | next 45 | } 46 | gsub(/\t/, " ") 47 | line = line " " $0 48 | gsub(/\/\*([^*]|\*+[^*\/])*\*+\//, " ", line) 49 | if(line ~ /\/\*/) 50 | continue 51 | # If it is a function definition, note so. 52 | if(line ~ /\) *(VA_DCL )*[{].*$/) #} 53 | isfunc = 1 54 | if(sub(/ *[{;].*$/, "", line)) #} 55 | break 56 | } 57 | if (!match(line, /VA_ALIST/)) { 58 | # Put spaces around each identifier. 59 | while(match(line, /[^_0-9A-Za-z ][_0-9A-Za-z]/) || 60 | match(line, /[_0-9A-Za-z][^_0-9A-Za-z ]/)) 61 | line = substr(line, 1, RSTART) " " substr(line, RSTART+1) 62 | } 63 | # Separate declarations into a type and a list of declarators. 64 | # In each declarator, "@{" and "@}" are used in place of parens to 65 | # mark function parameter lists, and "@!" is used in place of commas 66 | # in parameter lists. "@<" and "@>" are used in place of 67 | # non-parameter list parens. 68 | gsub(/ _ +/, " _ ", line) 69 | while(1) { 70 | if(isfunc && match(line, /\([^()]*\)$/)) 71 | line = substr(line, 1, RSTART-1) " _ (" substr(line, RSTART) ")" 72 | else if(match(line, / _ \(\([^,()]*,/)) 73 | line = substr(line, 1, RSTART+RLENGTH-2) "@!" substr(line, RSTART+RLENGTH) 74 | else if(match(line, / _ \(\([^,()]*\)\)/)) 75 | line = substr(line, 1, RSTART-1) "@{" substr(line, RSTART+5, RLENGTH-7) "@}" substr(line, RSTART+RLENGTH) 76 | else if(match(line, /\([^,()]*\)/)) 77 | line = substr(line, 1, RSTART-1) "@<" substr(line, RSTART+1, RLENGTH-2) "@>" substr(line, RSTART+RLENGTH) 78 | else 79 | break 80 | } 81 | sub(/^ */, "", line) 82 | match(line, /^((const|enum|mod_export|static|struct|union) +)*([_0-9A-Za-z]+ +|((char|double|float|int|long|short|unsigned|void) +)+)((const|static) +)*/) 83 | dtype = substr(line, 1, RLENGTH) 84 | sub(/ *$/, "", dtype) 85 | if(" " dtype " " ~ / static /) 86 | locality = "L" 87 | else 88 | locality = "E" 89 | exported = " " dtype " " ~ / mod_export / 90 | line = substr(line, RLENGTH+1) "," 91 | # Handle each declarator. 92 | if (match(line, /VA_ALIST/)) { 93 | # Already has VARARGS handling. 94 | 95 | # Put parens etc. back 96 | gsub(/@[{]/, "((", line) 97 | gsub(/@}/, "))", line) 98 | gsub(/@/, ")", line) 100 | gsub(/@!/, ",", line) 101 | sub(/,$/, ";", line) 102 | gsub(/mod_export/, "mod_import_function", dtype) 103 | gsub(/VA_ALIST/, "VA_ALIST_PROTO", line) 104 | sub(/ VA_DCL/, "", line) 105 | 106 | if(locality ~ /E/) 107 | dtype = "extern " dtype 108 | 109 | if (match(line, /[_0-9A-Za-z]+\(VA_ALIST/)) 110 | dnam = substr(line, RSTART, RLENGTH-9) 111 | 112 | # If this is exported, add it to the exported symbol list. 113 | if (exported) 114 | printf "X%s\n", dnam 115 | 116 | printf "%s%s %s\n", locality, dtype, line 117 | } else { 118 | while(match(line, /^[^,]*,/)) { 119 | # Separate out the name from the declarator. Use "@+" and "@-" 120 | # to bracket the name within the declarator. Strip off any 121 | # initialiser. 122 | dcltor = substr(line, 1, RLENGTH-1) 123 | line = substr(line, RLENGTH+1) 124 | sub(/=.*$/, "", dcltor) 125 | match(dcltor, /^([^_0-9A-Za-z]| const )*/) 126 | dcltor = substr(dcltor, 1, RLENGTH) "@+" substr(dcltor, RLENGTH+1) 127 | match(dcltor, /^.*@\+[_0-9A-Za-z]+/) 128 | dcltor = substr(dcltor, 1, RLENGTH) "@-" substr(dcltor, RLENGTH+1) 129 | dnam = dcltor 130 | sub(/^.*@\+/, "", dnam) 131 | sub(/@-.*$/, "", dnam) 132 | 133 | # Put parens etc. back 134 | gsub(/@[{]/, " _((", dcltor) 135 | gsub(/@}/, "))", dcltor) 136 | gsub(/@/, ")", dcltor) 138 | gsub(/@!/, ",", dcltor) 139 | 140 | # If this is exported, add it to the exported symbol list. 141 | if(exported) 142 | printf "X%s\n", dnam 143 | 144 | # Format the declaration for output 145 | dcl = dtype " " dcltor ";" 146 | if(locality ~ /E/) 147 | dcl = "extern " dcl 148 | if(isfunc) 149 | gsub(/ mod_export /, " mod_import_function ", dcl) 150 | else 151 | gsub(/ mod_export /, " mod_import_variable ", dcl) 152 | gsub(/@[+-]/, "", dcl) 153 | gsub(/ +/, " ", dcl) 154 | while(match(dcl, /[^_0-9A-Za-z] ./) || match(dcl, /. [^_0-9A-Za-z]/)) 155 | dcl = substr(dcl, 1, RSTART) substr(dcl, RSTART+2) 156 | printf "%s%s\n", locality, dcl 157 | } 158 | } 159 | } 160 | 161 | END { 162 | if(aborting) 163 | exit 1 164 | printf "E\n" 165 | printf "E#endif /* !have_%s_globals */\n", name 166 | } 167 | -------------------------------------------------------------------------------- /Src/mkbltnmlst.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # mkbltnmlst.sh: generate boot code for linked-in modules 4 | # 5 | # Written by Andrew Main 6 | # 7 | 8 | srcdir=${srcdir-`echo $0|sed 's%/[^/][^/]*$%%'`} 9 | test "x$srcdir" = "x$0" && srcdir=. 10 | test "x$srcdir" = "x" && srcdir=. 11 | CFMOD=${CFMOD-$srcdir/../config.modules} 12 | 13 | bin_mods="`grep ' link=static' $CFMOD | sed -e '/^#/d' \ 14 | -e 's/ .*/ /' -e 's/^name=/ /'`" 15 | 16 | x_mods="`grep ' load=yes' $CFMOD | sed -e '/^#/d' -e '/ link=no/d' \ 17 | -e 's/ .*/ /' -e 's/^name=/ /'`" 18 | 19 | trap "rm -f $1; exit 1" 1 2 15 20 | 21 | exec > $1 22 | 23 | for x_mod in $x_mods; do 24 | modfile="`grep '^name='$x_mod' ' $CFMOD | sed -e 's/^.* modfile=//' \ 25 | -e 's/ .*//'`" 26 | if test "x$modfile" = x; then 27 | echo >&2 "WARNING: no name for \`$x_mod' in $CFMOD (ignored)" 28 | continue 29 | fi 30 | case "$bin_mods" in 31 | *" $x_mod "*) 32 | echo "/* linked-in known module \`$x_mod' */" 33 | linked=yes 34 | ;; 35 | *) 36 | echo "#ifdef DYNAMIC" 37 | echo "/* non-linked-in known module \`$x_mod' */" 38 | linked=no 39 | esac 40 | unset moddeps autofeatures autofeatures_emu 41 | . $srcdir/../$modfile 42 | if test "x$autofeatures" != x; then 43 | if test "x$autofeatures_emu" != x; then 44 | echo " {" 45 | echo " char *zsh_features[] = { " 46 | for feature in $autofeatures; do 47 | echo " \"$feature\"," 48 | done 49 | echo " NULL" 50 | echo " }; " 51 | echo " char *emu_features[] = { " 52 | for feature in $autofeatures_emu; do 53 | echo " \"$feature\"," 54 | done 55 | echo " NULL" 56 | echo " }; " 57 | echo " autofeatures(\"zsh\", \"$x_mod\"," 58 | echo " EMULATION(EMULATE_ZSH) ? zsh_features : emu_features," 59 | echo " 0, 1);" 60 | echo " }" 61 | else 62 | echo " if (EMULATION(EMULATE_ZSH)) {" 63 | echo " char *features[] = { " 64 | for feature in $autofeatures; do 65 | echo " \"$feature\"," 66 | done 67 | echo " NULL" 68 | echo " }; " 69 | echo " autofeatures(\"zsh\", \"$x_mod\", features, 0, 1);" 70 | echo " }" 71 | fi 72 | fi 73 | for dep in $moddeps; do 74 | echo " add_dep(\"$x_mod\", \"$dep\");" 75 | done 76 | test "x$linked" = xno && echo "#endif" 77 | done 78 | 79 | echo 80 | done_mods=" " 81 | for bin_mod in $bin_mods; do 82 | q_bin_mod=`echo $bin_mod | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'` 83 | modfile="`grep '^name='$bin_mod' ' $CFMOD | sed -e 's/^.* modfile=//' \ 84 | -e 's/ .*//'`" 85 | echo "/* linked-in module \`$bin_mod' */" 86 | unset moddeps 87 | . $srcdir/../$modfile 88 | for dep in $moddeps; do 89 | # This assumes there are no circular dependencies in the builtin 90 | # modules. Better ordering of config.modules would be necessary 91 | # to enforce stricter dependency checking. 92 | case $bin_mods in 93 | *" $dep "*) 94 | echo " /* depends on \`$dep' */" ;; 95 | *) echo >&2 "ERROR: linked-in module \`$bin_mod' depends on \`$dep'" 96 | rm -f $1 97 | exit 1 ;; 98 | esac 99 | done 100 | echo " {" 101 | echo " extern int setup_${q_bin_mod} _((Module));" 102 | echo " extern int boot_${q_bin_mod} _((Module));" 103 | echo " extern int features_${q_bin_mod} _((Module,char***));" 104 | echo " extern int enables_${q_bin_mod} _((Module,int**));" 105 | echo " extern int cleanup_${q_bin_mod} _((Module));" 106 | echo " extern int finish_${q_bin_mod} _((Module));" 107 | echo 108 | echo " register_module(\"$bin_mod\"," 109 | echo " setup_${q_bin_mod}," 110 | echo " features_${q_bin_mod}," 111 | echo " enables_${q_bin_mod}," 112 | echo " boot_${q_bin_mod}," 113 | echo " cleanup_${q_bin_mod}, finish_${q_bin_mod});" 114 | echo " }" 115 | done_mods="$done_mods$bin_mod " 116 | done 117 | -------------------------------------------------------------------------------- /Src/prototypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * prototypes.h - prototypes header file 3 | * 4 | * This file is part of zsh, the Z shell. 5 | * 6 | * Copyright (c) 1992-1997 Paul Falstad 7 | * All rights reserved. 8 | * 9 | * Permission is hereby granted, without written agreement and without 10 | * license or royalty fees, to use, copy, modify, and distribute this 11 | * software and to distribute modified versions of this software for any 12 | * purpose, provided that the above copyright notice and the following 13 | * two paragraphs appear in all copies of this software. 14 | * 15 | * In no event shall Paul Falstad or the Zsh Development Group be liable 16 | * to any party for direct, indirect, special, incidental, or consequential 17 | * damages arising out of the use of this software and its documentation, 18 | * even if Paul Falstad and the Zsh Development Group have been advised of 19 | * the possibility of such damage. 20 | * 21 | * Paul Falstad and the Zsh Development Group specifically disclaim any 22 | * warranties, including, but not limited to, the implied warranties of 23 | * merchantability and fitness for a particular purpose. The software 24 | * provided hereunder is on an "as is" basis, and Paul Falstad and the 25 | * Zsh Development Group have no obligation to provide maintenance, 26 | * support, updates, enhancements, or modifications. 27 | * 28 | */ 29 | 30 | #ifndef HAVE_STDLIB_H 31 | char *malloc _((size_t)); 32 | char *realloc _((void *, size_t)); 33 | char *calloc _((size_t, size_t)); 34 | #endif 35 | 36 | #if !(defined(USES_TERMCAP_H) || defined(USES_TERM_H)) 37 | /* 38 | * These prototypes are only used where we don't have the 39 | * headers. In some cases they need tweaking. 40 | * TBD: we'd much prefer to get hold of the header where 41 | * these are defined. 42 | */ 43 | #ifdef _AIX 44 | #define TC_CONST const 45 | #else 46 | #define TC_CONST 47 | #endif 48 | extern int tgetent _((char *bp, TC_CONST char *name)); 49 | extern int tgetnum _((char *id)); 50 | extern int tgetflag _((char *id)); 51 | extern char *tgetstr _((char *id, char **area)); 52 | extern int tputs _((TC_CONST char *cp, int affcnt, int (*outc) (int))); 53 | #undef TC_CONST 54 | #endif 55 | 56 | /* 57 | * Some systems that do have termcap headers nonetheless don't 58 | * declare tgoto, so we detect if that is missing separately. 59 | */ 60 | #ifdef TGOTO_PROTO_MISSING 61 | char *tgoto(const char *cap, int col, int row); 62 | #endif 63 | 64 | /* MISSING PROTOTYPES FOR VARIOUS OPERATING SYSTEMS */ 65 | 66 | #if defined(__hpux) && defined(_HPUX_SOURCE) && !defined(_XPG4_EXTENDED) 67 | # define SELECT_ARG_2_T int * 68 | #else 69 | # define SELECT_ARG_2_T fd_set * 70 | #endif 71 | 72 | #ifdef __osf__ 73 | char *mktemp _((char *)); 74 | #endif 75 | 76 | #if defined(__osf__) && defined(__alpha) && defined(__GNUC__) 77 | /* Digital cc does not need these prototypes, gcc does need them */ 78 | # ifndef HAVE_IOCTL_PROTO 79 | int ioctl _((int d, unsigned long request, void *argp)); 80 | # endif 81 | # ifndef HAVE_MKNOD_PROTO 82 | int mknod _((const char *pathname, int mode, dev_t device)); 83 | # endif 84 | int nice _((int increment)); 85 | int select _((int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval *timeout)); 86 | #endif 87 | 88 | #if defined(DGUX) && defined(__STDC__) 89 | /* Just plain missing. */ 90 | extern int getrlimit _((int resource, struct rlimit *rlp)); 91 | extern int setrlimit _((int resource, const struct rlimit *rlp)); 92 | extern int getrusage _((int who, struct rusage *rusage)); 93 | extern int gettimeofday _((struct timeval *tv, struct timezone *tz)); 94 | extern int wait3 _((union wait *wait_status, int options, struct rusage *rusage)); 95 | extern int getdomainname _((char *name, int maxlength)); 96 | extern int select _((int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval *timeout)); 97 | #endif /* DGUX and __STDC__ */ 98 | 99 | #ifdef __NeXT__ 100 | extern pid_t getppid(void); 101 | #endif 102 | 103 | #if defined(__sun__) && !defined(__SVR4) /* SunOS */ 104 | extern char *strerror _((int errnum)); 105 | #endif 106 | 107 | /**************************************************/ 108 | /*** prototypes for functions built in compat.c ***/ 109 | #ifndef HAVE_STRSTR 110 | extern char *strstr _((const char *s, const char *t)); 111 | #endif 112 | 113 | #ifndef HAVE_GETHOSTNAME 114 | extern int gethostname _((char *name, size_t namelen)); 115 | #endif 116 | 117 | #ifndef HAVE_GETTIMEOFDAY 118 | extern int gettimeofday _((struct timeval *tv, struct timezone *tz)); 119 | #endif 120 | 121 | #ifndef HAVE_DIFFTIME 122 | extern double difftime _((time_t t2, time_t t1)); 123 | #endif 124 | 125 | #ifndef HAVE_STRERROR 126 | extern char *strerror _((int errnum)); 127 | #endif 128 | 129 | /*** end of prototypes for functions in compat.c ***/ 130 | /***************************************************/ 131 | 132 | #ifndef HAVE_MEMMOVE 133 | extern void bcopy _((const void *, void *, size_t)); 134 | #endif 135 | -------------------------------------------------------------------------------- /Src/signals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * signals.h - header file for signals handling code 3 | * 4 | * This file is part of zsh, the Z shell. 5 | * 6 | * Copyright (c) 1992-1997 Paul Falstad 7 | * All rights reserved. 8 | * 9 | * Permission is hereby granted, without written agreement and without 10 | * license or royalty fees, to use, copy, modify, and distribute this 11 | * software and to distribute modified versions of this software for any 12 | * purpose, provided that the above copyright notice and the following 13 | * two paragraphs appear in all copies of this software. 14 | * 15 | * In no event shall Paul Falstad or the Zsh Development Group be liable 16 | * to any party for direct, indirect, special, incidental, or consequential 17 | * damages arising out of the use of this software and its documentation, 18 | * even if Paul Falstad and the Zsh Development Group have been advised of 19 | * the possibility of such damage. 20 | * 21 | * Paul Falstad and the Zsh Development Group specifically disclaim any 22 | * warranties, including, but not limited to, the implied warranties of 23 | * merchantability and fitness for a particular purpose. The software 24 | * provided hereunder is on an "as is" basis, and Paul Falstad and the 25 | * Zsh Development Group have no obligation to provide maintenance, 26 | * support, updates, enhancements, or modifications. 27 | * 28 | */ 29 | 30 | #define SIGNAL_HANDTYPE void (*)_((int)) 31 | 32 | #ifndef HAVE_KILLPG 33 | # define killpg(pgrp,sig) kill(-(pgrp),sig) 34 | #endif 35 | 36 | #define SIGZERR (SIGCOUNT+1) 37 | #define SIGDEBUG (SIGCOUNT+2) 38 | #define VSIGCOUNT (SIGCOUNT+3) 39 | #define SIGEXIT 0 40 | 41 | #ifdef SV_BSDSIG 42 | # define SV_INTERRUPT SV_BSDSIG 43 | #endif 44 | 45 | /* If not a POSIX machine, then we create our * 46 | * own POSIX style signal sets functions. */ 47 | #ifndef POSIX_SIGNALS 48 | # define sigemptyset(s) (*(s) = 0) 49 | # if NSIG == 32 50 | # define sigfillset(s) (*(s) = ~(sigset_t)0, 0) 51 | # else 52 | # define sigfillset(s) (*(s) = (1 << NSIG) - 1, 0) 53 | # endif 54 | # define sigaddset(s,n) (*(s) |= (1 << ((n) - 1)), 0) 55 | # define sigdelset(s,n) (*(s) &= ~(1 << ((n) - 1)), 0) 56 | # define sigismember(s,n) ((*(s) & (1 << ((n) - 1))) != 0) 57 | #endif /* ifndef POSIX_SIGNALS */ 58 | 59 | #define child_block() signal_block(sigchld_mask) 60 | #define child_unblock() signal_unblock(sigchld_mask) 61 | 62 | #ifdef SIGWINCH 63 | # define winch_block() signal_block(signal_mask(SIGWINCH)) 64 | # define winch_unblock() signal_unblock(signal_mask(SIGWINCH)) 65 | #else 66 | # define winch_block() 0 67 | # define winch_unblock() 0 68 | #endif 69 | 70 | /* ignore a signal */ 71 | #define signal_ignore(S) signal(S, SIG_IGN) 72 | 73 | /* return a signal to it default action */ 74 | #define signal_default(S) signal(S, SIG_DFL) 75 | 76 | /* Use a circular queue to save signals caught during * 77 | * critical sections of code. You call queue_signals to * 78 | * start queueing, and unqueue_signals to process the * 79 | * queue and stop queueing. Since the kernel doesn't * 80 | * queue signals, it is probably overkill for zsh to do * 81 | * this, but it shouldn't hurt anything to do it anyway. */ 82 | 83 | #define MAX_QUEUE_SIZE 128 84 | 85 | #define run_queued_signals() do { \ 86 | while (queue_front != queue_rear) { /* while signals in queue */ \ 87 | sigset_t oset; \ 88 | queue_front = (queue_front + 1) % MAX_QUEUE_SIZE; \ 89 | oset = signal_setmask(signal_mask_queue[queue_front]); \ 90 | zhandler(signal_queue[queue_front]); /* handle queued signal */ \ 91 | signal_setmask(oset); \ 92 | } \ 93 | } while (0) 94 | 95 | #ifdef DEBUG 96 | 97 | #define queue_signals() (queue_in++, queueing_enabled++) 98 | 99 | #define unqueue_signals() do { \ 100 | DPUTS(!queueing_enabled, "BUG: unqueue_signals called but not queueing"); \ 101 | --queue_in; \ 102 | if (!--queueing_enabled) run_queued_signals(); \ 103 | } while (0) 104 | 105 | #define dont_queue_signals() do { \ 106 | queue_in = queueing_enabled; \ 107 | queueing_enabled = 0; \ 108 | run_queued_signals(); \ 109 | } while (0) 110 | 111 | #define restore_queue_signals(q) do { \ 112 | DPUTS2(queueing_enabled && queue_in != q, \ 113 | "BUG: q = %d != queue_in = %d", q, queue_in); \ 114 | queue_in = (queueing_enabled = (q)); \ 115 | } while (0) 116 | 117 | #else /* !DEBUG */ 118 | 119 | #define queue_signals() (queueing_enabled++) 120 | 121 | #define unqueue_signals() do { \ 122 | if (!--queueing_enabled) run_queued_signals(); \ 123 | } while (0) 124 | 125 | #define dont_queue_signals() do { \ 126 | queueing_enabled = 0; \ 127 | run_queued_signals(); \ 128 | } while (0) 129 | 130 | #define restore_queue_signals(q) (queueing_enabled = (q)) 131 | 132 | #endif /* DEBUG */ 133 | 134 | #define queue_signal_level() queueing_enabled 135 | 136 | #ifdef BSD_SIGNALS 137 | #define signal_block(S) sigblock(S) 138 | #else 139 | extern sigset_t signal_block _((sigset_t)); 140 | #endif /* BSD_SIGNALS */ 141 | 142 | extern sigset_t signal_unblock _((sigset_t)); 143 | -------------------------------------------------------------------------------- /Src/signames1.awk: -------------------------------------------------------------------------------- 1 | # This is an awk script which finds out what the possibilities for 2 | # the signal names are, and dumps them out so that cpp can turn them 3 | # into numbers. Since we don't need to decide here what the 4 | # real signals are, we can afford to be generous about definitions, 5 | # in case the definitions are in terms of other definitions. 6 | # However, we need to avoid definitions with parentheses, which will 7 | # mess up the syntax. 8 | BEGIN { printf "#include \n\n" } 9 | 10 | /^[\t ]*#[\t ]*define[\t _]*SIG[A-Z][A-Z0-9]*[\t ][\t ]*[^(\t ]/ { 11 | sigindex = index($0, "SIG") 12 | sigtail = substr($0, sigindex, 80) 13 | split(sigtail, tmp) 14 | signam = substr(tmp[1], 4, 20) 15 | if (substr($0, sigindex-1, 1) == "_") 16 | printf("XXNAMES XXSIG%s _SIG%s\n", signam, signam) 17 | else 18 | printf("XXNAMES XXSIG%s SIG%s\n", signam, signam) 19 | } 20 | -------------------------------------------------------------------------------- /Src/signames2.awk: -------------------------------------------------------------------------------- 1 | # 2 | # {g,n}awk script to generate signames.c 3 | # This version relies on the previous output of the preprocessor 4 | # on sigtmp.c, sigtmp.out, which is in turn generated by signames1.awk. 5 | # 6 | # NB: On SunOS 4.1.3 - user-functions don't work properly, also \" problems 7 | # Without 0 + hacks some nawks compare numbers as strings 8 | # 9 | /^[\t ]*XXNAMES XXSIG[A-Z][A-Z0-9]*[\t ][\t ]*[1-9][0-9]*/ { 10 | sigindex = index($0, "SIG") 11 | sigtail = substr($0, sigindex, 80) 12 | split(sigtail, tmp) 13 | signam = substr(tmp[1], 4, 20) 14 | signum = tmp[2] 15 | if (signam == "CHLD" && sig[signum] == "CLD") sig[signum] = "" 16 | if (signam == "POLL" && sig[signum] == "IO") sig[signum] = "" 17 | if (sig[signum] == "") { 18 | sig[signum] = signam 19 | if (0 + max < 0 + signum && signum < 60) 20 | max = signum 21 | if (signam == "ABRT") { msg[signum] = "abort" } 22 | if (signam == "ALRM") { msg[signum] = "alarm" } 23 | if (signam == "BUS") { msg[signum] = "bus error" } 24 | if (signam == "CHLD") { msg[signum] = "death of child" } 25 | if (signam == "CLD") { msg[signum] = "death of child" } 26 | if (signam == "CONT") { msg[signum] = "continued" } 27 | if (signam == "EMT") { msg[signum] = "EMT instruction" } 28 | if (signam == "FPE") { msg[signum] = "floating point exception" } 29 | if (signam == "HUP") { msg[signum] = "hangup" } 30 | if (signam == "ILL") { msg[signum] = "illegal hardware instruction" } 31 | if (signam == "INFO") { msg[signum] = "status request from keyboard" } 32 | if (signam == "INT") { msg[signum] = "interrupt" } 33 | if (signam == "IO") { msg[signum] = "i/o ready" } 34 | if (signam == "IOT") { msg[signum] = "IOT instruction" } 35 | if (signam == "KILL") { msg[signum] = "killed" } 36 | if (signam == "LOST") { msg[signum] = "resource lost" } 37 | if (signam == "PIPE") { msg[signum] = "broken pipe" } 38 | if (signam == "POLL") { msg[signum] = "pollable event occurred" } 39 | if (signam == "PROF") { msg[signum] = "profile signal" } 40 | if (signam == "PWR") { msg[signum] = "power fail" } 41 | if (signam == "QUIT") { msg[signum] = "quit" } 42 | if (signam == "SEGV") { msg[signum] = "segmentation fault" } 43 | if (signam == "SYS") { msg[signum] = "invalid system call" } 44 | if (signam == "TERM") { msg[signum] = "terminated" } 45 | if (signam == "TRAP") { msg[signum] = "trace trap" } 46 | if (signam == "URG") { msg[signum] = "urgent condition" } 47 | if (signam == "USR1") { msg[signum] = "user-defined signal 1" } 48 | if (signam == "USR2") { msg[signum] = "user-defined signal 2" } 49 | if (signam == "VTALRM") { msg[signum] = "virtual time alarm" } 50 | if (signam == "WINCH") { msg[signum] = "window size changed" } 51 | if (signam == "XCPU") { msg[signum] = "cpu limit exceeded" } 52 | if (signam == "XFSZ") { msg[signum] = "file size limit exceeded" } 53 | } 54 | } 55 | 56 | END { 57 | ps = "%s" 58 | ifdstr = sprintf("# ifdef USE_SUSPENDED\n\t%csuspended%s%c,\n%s else\n\t%cstopped%s%c,\n# endif\n", 34, ps, 34, "#", 34, ps, 34) 59 | 60 | printf "/** signames.c **/\n" 61 | printf "/** architecture-customized signames.c for zsh **/\n" 62 | printf "\n" 63 | printf "#define SIGCOUNT\t%d\n", max 64 | printf "\n" 65 | printf "#include %czsh.mdh%c\n", 34, 34 66 | printf "\n" 67 | printf "/**/\n" 68 | printf "#define sigmsg(sig) ((sig) <= SIGCOUNT ? sig_msg[sig]" 69 | printf " : %c%s%c)", 34, "unknown signal", 34 70 | printf "\n" 71 | printf "/**/\n" 72 | printf "mod_export char *sig_msg[SIGCOUNT+2] = {\n" 73 | printf "\t%c%s%c,\n", 34, "done", 34 74 | 75 | for (i = 1; i <= 0 + max; i++) 76 | if (msg[i] == "") { 77 | if (sig[i] == "") 78 | printf("\t%c%c,\n", 34, 34) 79 | else if (sig[i] == "STOP") 80 | printf ifdstr, " (signal)", " (signal)" 81 | else if (sig[i] == "TSTP") 82 | printf ifdstr, "", "" 83 | else if (sig[i] == "TTIN") 84 | printf ifdstr, " (tty input)", " (tty input)" 85 | else if (sig[i] == "TTOU") 86 | printf ifdstr, " (tty output)", " (tty output)" 87 | else 88 | printf("\t%cSIG%s%c,\n", 34, sig[i], 34) 89 | } else 90 | printf("\t%c%s%c,\n", 34, msg[i], 34) 91 | print "\tNULL" 92 | print "};" 93 | print "" 94 | print "/**/" 95 | printf "char *sigs[SIGCOUNT+4] = {\n" 96 | printf("\t%cEXIT%c,\n", 34, 34) 97 | for (i = 1; i <= 0 + max; i++) 98 | if (sig[i] == "") 99 | printf("\t%c%d%c,\n", 34, i, 34) 100 | else 101 | printf("\t%c%s%c,\n", 34, sig[i], 34) 102 | printf("\t%cZERR%c,\n", 34, 34) 103 | printf("\t%cDEBUG%c,\n", 34, 34) 104 | print "\tNULL" 105 | print "};" 106 | } 107 | -------------------------------------------------------------------------------- /Src/string.c: -------------------------------------------------------------------------------- 1 | /* 2 | * string.c - string manipulation 3 | * 4 | * This file is part of zsh, the Z shell. 5 | * 6 | * Copyright (c) 2000 Peter Stephenson 7 | * All rights reserved. 8 | * 9 | * Permission is hereby granted, without written agreement and without 10 | * license or royalty fees, to use, copy, modify, and distribute this 11 | * software and to distribute modified versions of this software for any 12 | * purpose, provided that the above copyright notice and the following 13 | * two paragraphs appear in all copies of this software. 14 | * 15 | * In no event shall Peter Stephenson or the Zsh Development Group be liable 16 | * to any party for direct, indirect, special, incidental, or consequential 17 | * damages arising out of the use of this software and its documentation, 18 | * even if Peter Stephenson and the Zsh Development Group have been advised of 19 | * the possibility of such damage. 20 | * 21 | * Peter Stephenson and the Zsh Development Group specifically disclaim any 22 | * warranties, including, but not limited to, the implied warranties of 23 | * merchantability and fitness for a particular purpose. The software 24 | * provided hereunder is on an "as is" basis, and Peter Stephenson and the 25 | * Zsh Development Group have no obligation to provide maintenance, 26 | * support, updates, enhancements, or modifications. 27 | */ 28 | 29 | #include "zsh.mdh" 30 | 31 | /**/ 32 | mod_export char * 33 | dupstring(const char *s) 34 | { 35 | char *t; 36 | 37 | if (!s) 38 | return NULL; 39 | t = (char *) zhalloc(strlen((char *)s) + 1); 40 | strcpy(t, s); 41 | return t; 42 | } 43 | 44 | /* Duplicate string on heap when length is known */ 45 | 46 | /**/ 47 | mod_export char * 48 | dupstring_wlen(const char *s, unsigned len) 49 | { 50 | char *t; 51 | 52 | if (!s) 53 | return NULL; 54 | t = (char *) zhalloc(len + 1); 55 | memcpy(t, s, len); 56 | t[len] = '\0'; 57 | return t; 58 | } 59 | 60 | /* Duplicate string on heap, returning length of string */ 61 | 62 | /**/ 63 | mod_export char * 64 | dupstring_glen(const char *s, unsigned *len_ret) 65 | { 66 | char *t; 67 | 68 | if (!s) 69 | return NULL; 70 | t = (char *) zhalloc((*len_ret = strlen((char *)s)) + 1); 71 | strcpy(t, s); 72 | return t; 73 | } 74 | 75 | /**/ 76 | mod_export char * 77 | ztrdup(const char *s) 78 | { 79 | char *t; 80 | 81 | if (!s) 82 | return NULL; 83 | t = (char *)zalloc(strlen((char *)s) + 1); 84 | strcpy(t, s); 85 | return t; 86 | } 87 | 88 | /**/ 89 | #ifdef MULTIBYTE_SUPPORT 90 | /**/ 91 | mod_export wchar_t * 92 | wcs_ztrdup(const wchar_t *s) 93 | { 94 | wchar_t *t; 95 | 96 | if (!s) 97 | return NULL; 98 | t = (wchar_t *)zalloc(sizeof(wchar_t) * (wcslen((wchar_t *)s) + 1)); 99 | wcscpy(t, s); 100 | return t; 101 | } 102 | /**/ 103 | #endif /* MULTIBYTE_SUPPORT */ 104 | 105 | 106 | /* Concatenate s1, s2, and s3 into dynamically allocated buffer. 107 | * 108 | * To concatenate four or more strings, see zjoin(). 109 | */ 110 | 111 | /**/ 112 | mod_export char * 113 | tricat(char const *s1, char const *s2, char const *s3) 114 | { 115 | /* This version always uses permanently-allocated space. */ 116 | char *ptr; 117 | size_t l1 = strlen(s1); 118 | size_t l2 = strlen(s2); 119 | 120 | ptr = (char *)zalloc(l1 + l2 + strlen(s3) + 1); 121 | strcpy(ptr, s1); 122 | strcpy(ptr + l1, s2); 123 | strcpy(ptr + l1 + l2, s3); 124 | return ptr; 125 | } 126 | 127 | /**/ 128 | mod_export char * 129 | zhtricat(char const *s1, char const *s2, char const *s3) 130 | { 131 | char *ptr; 132 | size_t l1 = strlen(s1); 133 | size_t l2 = strlen(s2); 134 | 135 | ptr = (char *)zhalloc(l1 + l2 + strlen(s3) + 1); 136 | strcpy(ptr, s1); 137 | strcpy(ptr + l1, s2); 138 | strcpy(ptr + l1 + l2, s3); 139 | return ptr; 140 | } 141 | 142 | /* concatenate s1 and s2 in dynamically allocated buffer */ 143 | 144 | /**/ 145 | mod_export char * 146 | dyncat(const char *s1, const char *s2) 147 | { 148 | /* This version always uses space from the current heap. */ 149 | char *ptr; 150 | size_t l1 = strlen(s1); 151 | 152 | ptr = (char *)zhalloc(l1 + strlen(s2) + 1); 153 | strcpy(ptr, s1); 154 | strcpy(ptr + l1, s2); 155 | return ptr; 156 | } 157 | 158 | /**/ 159 | mod_export char * 160 | bicat(const char *s1, const char *s2) 161 | { 162 | /* This version always uses permanently-allocated space. */ 163 | char *ptr; 164 | size_t l1 = strlen(s1); 165 | 166 | ptr = (char *)zalloc(l1 + strlen(s2) + 1); 167 | strcpy(ptr, s1); 168 | strcpy(ptr + l1, s2); 169 | return ptr; 170 | } 171 | 172 | /* like dupstring(), but with a specified length */ 173 | 174 | /**/ 175 | mod_export char * 176 | dupstrpfx(const char *s, int len) 177 | { 178 | char *r = zhalloc(len + 1); 179 | 180 | memcpy(r, s, len); 181 | r[len] = '\0'; 182 | return r; 183 | } 184 | 185 | /**/ 186 | mod_export char * 187 | ztrduppfx(const char *s, int len) 188 | { 189 | /* This version always uses permanently-allocated space. */ 190 | char *r = zalloc(len + 1); 191 | 192 | memcpy(r, s, len); 193 | r[len] = '\0'; 194 | return r; 195 | } 196 | 197 | /* Append a string to an allocated string, reallocating to make room. */ 198 | 199 | /**/ 200 | mod_export char * 201 | appstr(char *base, char const *append) 202 | { 203 | return strcat(realloc(base, strlen(base) + strlen(append) + 1), append); 204 | } 205 | 206 | /* Return a pointer to the last character of a string, 207 | unless the string is empty. */ 208 | 209 | /**/ 210 | mod_export char * 211 | strend(char *str) 212 | { 213 | if (*str == '\0') 214 | return str; 215 | return str + strlen (str) - 1; 216 | } 217 | -------------------------------------------------------------------------------- /Src/zi/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | *.export 4 | so_locations 5 | *.pro 6 | *.epro 7 | *.syms 8 | *.o 9 | *.o.c 10 | *.so 11 | *.mdh 12 | *.mdhi 13 | *.mdhs 14 | *.mdh.tmp 15 | *.swp 16 | errnames.c errcount.h 17 | *.dll 18 | curses_keys.h 19 | -------------------------------------------------------------------------------- /Src/zi/.distfiles: -------------------------------------------------------------------------------- 1 | DISTFILES_SRC=' 2 | ' 3 | -------------------------------------------------------------------------------- /Src/zi/.exrc: -------------------------------------------------------------------------------- 1 | set ai 2 | set sw=4 3 | -------------------------------------------------------------------------------- /Src/zi/zpmod.mdd: -------------------------------------------------------------------------------- 1 | name=zi/zpmod 2 | link=dynamic 3 | load=no 4 | 5 | autofeatures="" 6 | 7 | objects="zpmod.o" 8 | -------------------------------------------------------------------------------- /Src/zsh.mdd: -------------------------------------------------------------------------------- 1 | name=zsh/main 2 | link=static 3 | load=yes 4 | # load=static should replace use of alwayslink 5 | functions='Functions/Chpwd/* Functions/Exceptions/* Functions/Math/* Functions/Misc/* Functions/MIME/* Functions/Prompts/* Functions/VCS_Info/* Functions/VCS_Info/Backends/*' 6 | 7 | nozshdep=1 8 | alwayslink=1 9 | 10 | # autofeatures not specified because of alwayslink 11 | 12 | objects="signames.o builtin.o module.o lex.o exec.o mem.o \ 13 | string.o parse.o hashtable.o init.o input.o loop.o utils.o params.o options.o \ 14 | signals.o pattern.o prompt.o compat.o jobs.o glob.o" 15 | 16 | headers="../config.h zsh_system.h zsh.h sigcount.h signals.h \ 17 | prototypes.h hashtable.h ztype.h" 18 | hdrdeps="zshcurses.h zshterm.h" 19 | 20 | :<<\Make 21 | @CONFIG_MK@ 22 | 23 | # If we're using gcc as the preprocessor, get rid of the additional 24 | # lines generated by the preprocessor as they can confuse the script. 25 | # We don't need these in other cases either, but can't necessarily rely 26 | # on the option to remove them being the same. 27 | signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@ 28 | $(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c 29 | case "`$(CPP) --version &1`" in \ 30 | *"Free Software Foundation"*) \ 31 | $(CPP) -P sigtmp.c >sigtmp.out;; \ 32 | *) \ 33 | $(CPP) sigtmp.c >sigtmp.out;; \ 34 | esac 35 | $(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@ 36 | rm -f sigtmp.c sigtmp.out 37 | 38 | sigcount.h: signames.c 39 | grep 'define.*SIGCOUNT' signames.c > $@ 40 | 41 | init.o: bltinmods.list zshpaths.h zshxmods.h 42 | 43 | init.o params.o parse.o: version.h 44 | 45 | params.o: patchlevel.h 46 | 47 | version.h: $(sdir_top)/Config/version.mk zshcurses.h zshterm.h 48 | echo '#define ZSH_VERSION "'$(VERSION)'"' > $@ 49 | 50 | patchlevel.h: FORCE 51 | @if [ -f $(sdir)/$@.release ]; then \ 52 | cp -f $(sdir)/$@.release $@; \ 53 | else \ 54 | echo '#define ZSH_PATCHLEVEL "'`cd $(sdir) && git describe --tags --long`'"' > $@.tmp; \ 55 | cmp $@ $@.tmp >/dev/null 2>&1 && rm -f $@.tmp || mv $@.tmp $@; \ 56 | fi 57 | FORCE: 58 | 59 | zshcurses.h: ../config.h 60 | @if test x$(ZSH_CURSES_H) != x; then \ 61 | echo "#include <$(ZSH_CURSES_H)>" >zshcurses.h; \ 62 | else \ 63 | echo >zshcurses.h; \ 64 | fi 65 | 66 | zshterm.h: ../config.h 67 | @if test x$(ZSH_TERM_H) != x; then \ 68 | echo "#include <$(ZSH_TERM_H)>" >zshterm.h; \ 69 | else \ 70 | echo >zshterm.h; \ 71 | fi 72 | 73 | zshpaths.h: Makemod $(CONFIG_INCS) 74 | @echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp 75 | @if test x$(sitescriptdir) != xno; then \ 76 | echo '#define SITESCRIPT_DIR "'$(sitescriptdir)'"' >> zshpaths.h.tmp; \ 77 | fi 78 | @if test x$(scriptdir) != xno; then \ 79 | echo '#define SCRIPT_DIR "'$(scriptdir)'"' >> zshpaths.h.tmp; \ 80 | fi 81 | @if test x$(sitefndir) != xno; then \ 82 | echo '#define SITEFPATH_DIR "'$(sitefndir)'"' >> zshpaths.h.tmp; \ 83 | fi 84 | @if test x$(fixed_sitefndir) != x; then \ 85 | echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp; \ 86 | fi 87 | @if test x$(fndir) != xno; then \ 88 | echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \ 89 | if test x$(FUNCTIONS_SUBDIRS) != x && \ 90 | test x$(FUNCTIONS_SUBDIRS) != xno; then \ 91 | fpath_tmp="`grep ' functions=.' \ 92 | $(dir_top)/config.modules | sed -e '/^#/d' -e '/ link=no/d' \ 93 | -e 's/^.* functions=//'`"; \ 94 | fpath_tmp=`for f in $$fpath_tmp; do \ 95 | echo $$f | sed -e 's%^Functions/%%' -e 's%/[^/]*$$%%' -e 's%/\*%%'; \ 96 | done | grep -v Scripts | sort | uniq`; \ 97 | fpath_tmp=`echo $$fpath_tmp | sed 's/ /\", \"/g'`; \ 98 | echo "#define FPATH_SUBDIRS { \"$$fpath_tmp\" }" \ 99 | >>zshpaths.h.tmp; \ 100 | fi; \ 101 | fi 102 | @if test x$(additionalfpath) != x; then \ 103 | fpath_tmp="`echo $(additionalfpath) | sed -e 's:,:\", \":g'`"; \ 104 | echo "#define ADDITIONAL_FPATH { \"$$fpath_tmp\" }" >> zshpaths.h.tmp; \ 105 | fi 106 | @if cmp -s zshpaths.h zshpaths.h.tmp; then \ 107 | rm -f zshpaths.h.tmp; \ 108 | echo "\`zshpaths.h' is up to date." ; \ 109 | else \ 110 | mv -f zshpaths.h.tmp zshpaths.h; \ 111 | echo "Updated \`zshpaths.h'." ; \ 112 | fi 113 | 114 | bltinmods.list: modules.stamp mkbltnmlst.sh $(dir_top)/config.modules 115 | srcdir='$(sdir)' CFMOD='$(dir_top)/config.modules' \ 116 | $(SHELL) $(sdir)/mkbltnmlst.sh $@ 117 | 118 | zshxmods.h: $(dir_top)/config.modules 119 | @echo "Creating \`$@'." 120 | @( \ 121 | for q_mod in `grep ' load=yes' $(dir_top)/config.modules | \ 122 | grep ' link=static' | sed -e '/^#/d' -e 's/ .*//' \ 123 | -e 's/^name=//' -e 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`; do \ 124 | test x$q_mod = xzshQsmain && continue; \ 125 | echo "#define LINKED_XMOD_$$q_mod 1"; \ 126 | done; \ 127 | for q_mod in `grep ' load=yes' $(dir_top)/config.modules | \ 128 | grep ' link=dynamic' | sed -e '/^#/d' -e 's/ .*//' \ 129 | -e 's/^name=//' -e 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`; do \ 130 | test x$q_mod = x && continue; \ 131 | echo "#ifdef DYNAMIC"; \ 132 | echo "# define UNLINKED_XMOD_$$q_mod 1"; \ 133 | echo "#endif"; \ 134 | done; \ 135 | ) > $@ 136 | 137 | clean-here: clean.zsh 138 | clean.zsh: 139 | rm -f sigcount.h signames.c bltinmods.list version.h zshpaths.h zshxmods.h 140 | 141 | # This is not properly part of this module, but it is built as if it were. 142 | main.o: main.c zsh.mdh main.epro 143 | $(CC) -c -I. -I$(sdir_top)/Src $(CPPFLAGS) $(DEFS) $(CFLAGS) -o $@ $(sdir)/main.c 144 | 145 | main.syms: $(PROTODEPS) 146 | proto.zsh: main.epro 147 | Make 148 | -------------------------------------------------------------------------------- /Src/zsh.rc: -------------------------------------------------------------------------------- 1 | // Use this file as follows 2 | // 3 | // myapp.exe : myapp.o myapp.res 4 | // gcc -mwindows myapp.o myapp.res -o $@ 5 | // 6 | // myapp.res : myapp.rc resource.h 7 | // windres $< -O coff -o $@ 8 | IDR_MAINFRAME ICON DISCARDABLE "zsh.ico" 9 | -------------------------------------------------------------------------------- /Src/ztype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ztype.h - character classification macros 3 | * 4 | * This file is part of zsh, the Z shell. 5 | * 6 | * Copyright (c) 1992-1997 Paul Falstad 7 | * All rights reserved. 8 | * 9 | * Permission is hereby granted, without written agreement and without 10 | * license or royalty fees, to use, copy, modify, and distribute this 11 | * software and to distribute modified versions of this software for any 12 | * purpose, provided that the above copyright notice and the following 13 | * two paragraphs appear in all copies of this software. 14 | * 15 | * In no event shall Paul Falstad or the Zsh Development Group be liable 16 | * to any party for direct, indirect, special, incidental, or consequential 17 | * damages arising out of the use of this software and its documentation, 18 | * even if Paul Falstad and the Zsh Development Group have been advised of 19 | * the possibility of such damage. 20 | * 21 | * Paul Falstad and the Zsh Development Group specifically disclaim any 22 | * warranties, including, but not limited to, the implied warranties of 23 | * merchantability and fitness for a particular purpose. The software 24 | * provided hereunder is on an "as is" basis, and Paul Falstad and the 25 | * Zsh Development Group have no obligation to provide maintenance, 26 | * support, updates, enhancements, or modifications. 27 | * 28 | */ 29 | 30 | #define IDIGIT (1 << 0) 31 | #define IALNUM (1 << 1) 32 | #define IBLANK (1 << 2) 33 | #define INBLANK (1 << 3) 34 | #define ITOK (1 << 4) 35 | #define ISEP (1 << 5) 36 | #define IALPHA (1 << 6) 37 | #define IIDENT (1 << 7) 38 | #define IUSER (1 << 8) 39 | #define ICNTRL (1 << 9) 40 | #define IWORD (1 << 10) 41 | #define ISPECIAL (1 << 11) 42 | #define IMETA (1 << 12) 43 | #define IWSEP (1 << 13) 44 | #define INULL (1 << 14) 45 | #define IPATTERN (1 << 15) 46 | #define zistype(X,Y) (typtab[(unsigned char) (X)] & Y) 47 | #define idigit(X) zistype(X,IDIGIT) 48 | #define ialnum(X) zistype(X,IALNUM) 49 | #define iblank(X) zistype(X,IBLANK) /* blank, not including \n */ 50 | #define inblank(X) zistype(X,INBLANK) /* blank or \n */ 51 | #define itok(X) zistype(X,ITOK) 52 | #define isep(X) zistype(X,ISEP) 53 | #define ialpha(X) zistype(X,IALPHA) 54 | #define iident(X) zistype(X,IIDENT) 55 | #define iuser(X) zistype(X,IUSER) /* username char */ 56 | #define icntrl(X) zistype(X,ICNTRL) 57 | #define iword(X) zistype(X,IWORD) 58 | #define ispecial(X) zistype(X,ISPECIAL) 59 | #define imeta(X) zistype(X,IMETA) 60 | #define iwsep(X) zistype(X,IWSEP) 61 | #define inull(X) zistype(X,INULL) 62 | #define ipattern(X) zistype(X,IPATTERN) 63 | 64 | /* 65 | * Bit flags for typtab_flags --- preserved after 66 | * shell initialisation. 67 | */ 68 | #define ZTF_INIT (0x0001) /* One-off initialisation done */ 69 | #define ZTF_INTERACT (0x0002) /* Shell interactive and reading from stdin */ 70 | #define ZTF_SP_COMMA (0x0004) /* Treat comma as a special characters */ 71 | #define ZTF_BANGCHAR (0x0008) /* Treat bangchar as a special character */ 72 | 73 | #ifdef MULTIBYTE_SUPPORT 74 | #define WC_ZISTYPE(X,Y) wcsitype((X),(Y)) 75 | # ifdef ENABLE_UNICODE9 76 | # define WC_ISPRINT(X) u9_iswprint(X) 77 | # else 78 | # define WC_ISPRINT(X) iswprint(X) 79 | # endif 80 | #else 81 | #define WC_ZISTYPE(X,Y) zistype((X),(Y)) 82 | #define WC_ISPRINT(X) isprint(X) 83 | #endif 84 | 85 | #if defined(__APPLE__) && defined(BROKEN_ISPRINT) 86 | #define ZISPRINT(c) isprint_ascii(c) 87 | #else 88 | #define ZISPRINT(c) isprint(c) 89 | #endif 90 | -------------------------------------------------------------------------------- /Test/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.tmp 3 | *.swp 4 | -------------------------------------------------------------------------------- /Test/.distfiles: -------------------------------------------------------------------------------- 1 | DISTFILES_SRC=' 2 | ' 3 | -------------------------------------------------------------------------------- /Test/A02alias.ztst: -------------------------------------------------------------------------------- 1 | # To get the "command not found" message when aliasing is suppressed 2 | # we need, er, a command that isn't found. 3 | # The other aliases are only ever used as aliases. 4 | 5 | %prep 6 | alias ThisCommandDefinitelyDoesNotExist=echo 7 | 8 | alias -g bar=echo 9 | 10 | alias '\bar=echo' 11 | 12 | %test 13 | ThisCommandDefinitelyDoesNotExist ThisCommandDefinitelyDoesNotExist 14 | 0:Basic aliasing 15 | >ThisCommandDefinitelyDoesNotExist 16 | 17 | bar bar 18 | 0:Global aliasing 19 | >echo 20 | 21 | \ThisCommandDefinitelyDoesNotExist ThisCommandDefinitelyDoesNotExist 22 | 127:Not aliasing 23 | ?(eval):1: command not found: ThisCommandDefinitelyDoesNotExist 24 | 25 | \bar \bar 26 | 0:Aliasing with a backslash 27 | >bar 28 | 29 | (alias '!=echo This command has the argument' 30 | eval 'print Without 31 | ! true' 32 | setopt posixaliases 33 | eval 'print With 34 | ! true') 35 | 1:POSIX_ALIASES option 36 | >Without 37 | >This command has the argument true 38 | >With 39 | 40 | print -u $ZTST_fd 'This test hangs the shell when it fails...' 41 | alias cat='LC_ALL=C cat' 42 | cat <(echo foo | cat) 43 | 0:Alias expansion works at the end of parsed strings 44 | >foo 45 | 46 | alias -g '&&=(){ return $?; } && ' 47 | alias not_the_print_command=print 48 | eval 'print This is output 49 | && print And so is this 50 | && { print And this too; false; } 51 | && print But not this 52 | && print Nor this 53 | true 54 | && not_the_print_command And aliases are expanded' 55 | 0:We can now alias special tokens. Woo hoo. 56 | >This is output 57 | >And so is this 58 | >And this too 59 | >And aliases are expanded 60 | 61 | $ZTST_testdir/../Src/zsh -fis <<<' 62 | unsetopt PROMPT_SP 63 | PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2="" 64 | exec 2>&1 65 | alias \{=echo 66 | { begin 67 | {end 68 | fc -l -2' 2>/dev/null 69 | 0:Aliasing reserved tokens 70 | >begin 71 | >end 72 | *>*5*{ begin 73 | *>*6*{end 74 | 75 | $ZTST_testdir/../Src/zsh -fis <<<' 76 | unsetopt PROMPT_SP 77 | PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2="" 78 | exec 2>&1 79 | alias -g S=\" 80 | echo S a string S " 81 | fc -l -1' 2>/dev/null 82 | 0:Global aliasing quotes 83 | > a string S 84 | *>*5*echo S a string S " 85 | # " 86 | # Note there is a trailing space on the "> a string S " line 87 | 88 | ( 89 | unalias -a 90 | alias 91 | ) 92 | 0:unalias -a 93 | 94 | alias -s foo=print 95 | type bar.foo; type -w bar.foo 96 | unalias -as 97 | 0:unalias -as 98 | >foo is a suffix alias for print 99 | >foo: suffix alias 100 | 101 | aliases[x=y]=z 102 | alias -L | grep x=y 103 | echo $pipestatus[1] 104 | 0:printing invalid aliases warns 105 | >0 106 | ?(eval):2: invalid alias 'x=y' encountered while printing aliases 107 | # Currently, 'alias -L' returns 0 in this case. Perhaps it should return 1. 108 | 109 | alias -s mysuff='print -r "You said it.";' 110 | eval 'thingummy.mysuff' 111 | 127:No endless loop with suffix alias in command position 112 | >You said it. 113 | ?(eval):1: command not found: thingummy.mysuff 114 | 115 | alias +x; alias -z 116 | 1:error message has the correct sign 117 | ?(eval):alias:1: bad option: +x 118 | ?(eval):alias:1: bad option: -z 119 | 120 | # Usual issue that aliases aren't expanded until we 121 | # trigger a new parse... 122 | (alias badalias=notacommand 123 | eval 'badalias() { print does not work; }') 124 | 1:ALIAS_FUNC_DEF off by default. 125 | ?(eval):1: defining function based on alias `badalias' 126 | ?(eval):1: parse error near `()' 127 | 128 | (alias goodalias=isafunc 129 | setopt ALIAS_FUNC_DEF 130 | eval 'goodalias() { print does now work; }' 131 | isafunc) 132 | 0:ALIAS_FUNC_DEF causes the icky behaviour to be avaliable 133 | >does now work 134 | 135 | (alias thisisokthough='thisworks() { print That worked; }' 136 | eval thisisokthough 137 | thisworks) 138 | 0:NO_ALIAS_FUNC_DEF works if the alias is a complete definition 139 | >That worked 140 | -------------------------------------------------------------------------------- /Test/A03quoting.ztst: -------------------------------------------------------------------------------- 1 | %test 2 | print 'single quotes' "double quotes" `echo backquotes` 3 | 0:Simple use of quotes 4 | >single quotes double quotes backquotes 5 | 6 | foo=text 7 | print -r '$foo\\\' "$foo\$foo\\\"\``echo bar`\`\"" `print -r $foo\\\`` 8 | 0:Quoting inside quotes 9 | >$foo\\\ text$foo\"`bar`" text` 10 | 11 | print -r $'\'ut queant laxis\'\n"resonare fibris"' 12 | 0:$'-style quotes 13 | >'ut queant laxis' 14 | >"resonare fibris" 15 | 16 | print -r $'\'a \\\' is \'a backslash\' is \'a \\\'' 17 | 0:$'-style quotes with backslashed backslashes 18 | >'a \' is 'a backslash' is 'a \' 19 | 20 | chars=$(print -r $'BS\\MBS\M-\\') 21 | for (( i = 1; i <= $#chars; i++ )); do 22 | char=$chars[$i] 23 | print $(( [#16] #char )) 24 | done 25 | 0:$'-style quote with metafied backslash 26 | >16#42 27 | >16#53 28 | >16#5C 29 | >16#4D 30 | >16#42 31 | >16#53 32 | >16#DC 33 | 34 | print -r '''' 35 | setopt rcquotes 36 | # We need to set rcquotes here for the next example since it is 37 | # needed while parsing. 38 | 0:No RC_QUOTES with single quotes 39 | > 40 | 41 | print -r '''' 42 | unsetopt rcquotes 43 | 0:Yes RC_QUOTES with single quotes 44 | >' 45 | # ' Deconfuse Emacs quoting rules 46 | 47 | print '<\u0041>' 48 | printf '%s\n' $'<\u0042>' 49 | print '<\u0043>' 50 | printf '%s\n' $'<\u0044>' 51 | 0:\u in both print and printf 52 | > 53 | > 54 | > 55 | > 56 | 57 | null1="$(print -r a$'b\0c'd)" 58 | null2="$(setopt posixstrings; print -r a$'b\0c'd)" 59 | for string in $null1 $null2; do 60 | print ":" 61 | for (( i = 1; i <= $#string; i++ )); do 62 | char=$string[$i] 63 | print $(( [#16] #char )) 64 | done 65 | done 66 | 0:Embedded null characters in $'...' strings. 67 | >: 68 | >16#61 69 | >16#62 70 | >16#0 71 | >16#63 72 | >16#64 73 | >: 74 | >16#61 75 | >16#62 76 | >16#64 77 | 78 | () { print $# } '' "" $'' 79 | 0:$'' should not be elided, in common with other empty quotes 80 | >3 81 | -------------------------------------------------------------------------------- /Test/A05execution.ztst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-shell/zpmod/e1c5aabc69f09103971020d6de8c1fad722a3946/Test/A05execution.ztst -------------------------------------------------------------------------------- /Test/A07control.ztst: -------------------------------------------------------------------------------- 1 | # Test control commands for loops and functions. 2 | 3 | %test 4 | 5 | fn3() { return $1; print Error } 6 | fn2() { fn3 $1 } 7 | fn() { 8 | print start $1 9 | fn2 $1 10 | return 11 | print Error 12 | } 13 | for val in -1 0 1 255; do 14 | fn $val; print $? 15 | done 16 | 0:Passing of return values back through functions 17 | >start -1 18 | >-1 19 | >start 0 20 | >0 21 | >start 1 22 | >1 23 | >start 255 24 | >255 25 | 26 | $ZTST_testdir/../Src/zsh -fc 'fn() { 27 | continue 28 | } 29 | fn' 30 | 1:continue outside loop 31 | ?fn:continue:1: not in while, until, select, or repeat loop 32 | 33 | for outer in 0 1 2 3; do 34 | print outer $outer 35 | for inner in 0 1 2 3; do 36 | print inner $inner 37 | continue $(( (outer & 1) ? 2 : 1 )) 38 | print error 39 | done 40 | print outer end 41 | done 42 | 0:continue with valid argument 43 | >outer 0 44 | >inner 0 45 | >inner 1 46 | >inner 2 47 | >inner 3 48 | >outer end 49 | >outer 1 50 | >inner 0 51 | >outer 2 52 | >inner 0 53 | >inner 1 54 | >inner 2 55 | >inner 3 56 | >outer end 57 | >outer 3 58 | >inner 0 59 | 60 | for outer in 0 1; do 61 | continue 0 62 | print -- $outer got here, status $? 63 | done 64 | 1:continue error case 0 65 | ?(eval):continue:2: argument is not positive: 0 66 | 67 | for outer in 0 1; do 68 | continue -1 69 | print -- $outer got here, status $? 70 | done 71 | 1:continue error case -1 72 | ?(eval):continue:2: argument is not positive: -1 73 | 74 | fn() { 75 | break 76 | } 77 | for outer in 0 1; do 78 | print $outer 79 | fn 80 | done 81 | 0:break from within function (this is a feature, I disovered) 82 | >0 83 | 84 | for outer in 0 1 2 3; do 85 | print outer $outer 86 | for inner in 0 1 2 3; do 87 | print inner $inner 88 | break $(( (outer & 1) ? 2 : 1 )) 89 | print error 90 | done 91 | print outer end 92 | done 93 | 0:break with valid argument 94 | >outer 0 95 | >inner 0 96 | >outer end 97 | >outer 1 98 | >inner 0 99 | 100 | for outer in 0 1; do 101 | break 0 102 | print -- $outer got here, status $? 103 | done 104 | 1:break error case 0 105 | ?(eval):break:2: argument is not positive: 0 106 | 107 | for outer in 0 1; do 108 | break -1 109 | print -- $outer got here, status $? 110 | done 111 | 1:break error case -1 112 | ?(eval):break:2: argument is not positive: -1 113 | 114 | false 115 | for x in; do 116 | print nothing executed 117 | done 118 | 0:Status 0 from for with explicit empty list 119 | 120 | set -- 121 | false 122 | for x; do 123 | print nothing executed 124 | done 125 | 0:Status 0 from for with implicit empty list 126 | 127 | (exit 2) 128 | for x in 1 2; do 129 | print $? 130 | done 131 | 0:Status from previous command propagated into for loop 132 | >2 133 | >0 134 | 135 | false 136 | for x in $(echo 1 2; (exit 3)); do 137 | print $? 138 | done 139 | 0:Status from expansion propagated into for loop 140 | >3 141 | >0 142 | 143 | false 144 | for x in $(exit 4); do 145 | print not executed 146 | done 147 | 0:Status from expansion not propagated after unexecuted for loop 148 | 149 | false 150 | for x in NonExistentFilePrefix*(N); do 151 | print not executed, either 152 | done 153 | 0:Status from before for loop not propagated if empty after expansion 154 | 155 | for x in $(echo 1; false); do 156 | done 157 | 0:Status reset by empty list in for loop 158 | 159 | false 160 | for x in $(echo 1; false); do 161 | echo $? 162 | (exit 4) 163 | done 164 | 4:Last status from loop body is kept even with other funny business going on 165 | >1 166 | -------------------------------------------------------------------------------- /Test/B01cd.ztst: -------------------------------------------------------------------------------- 1 | # This file serves as a model for how to write tests, so is more heavily 2 | # commented than the others. All tests are run in the Test subdirectory 3 | # of the distribution, which must be writable. They should end with 4 | # the suffix `.ztst': this is not required by the test harness itself, 5 | # but it is needed by the Makefile to run all the tests. 6 | 7 | # Blank lines with no other special meaning (e.g. separating chunks of 8 | # code) and all those with a `#' in the first column are ignored. 9 | 10 | # All section names start with a % in the first column. The names 11 | # must be in the expected order, though not all sections are required. 12 | # The sections are %prep (preparatory setup: code executed should return 13 | # status 0, but no other tests are performed), %test (the main tests), and 14 | # %clean (to cleanup: the code is simply unconditionally executed). 15 | # 16 | # Literal shell code to be evaluated must be indented with any number 17 | # of spaces and/or tabs, to differentiate it from tags with a special 18 | # meaning to the test harness. Note that this is true even in sections 19 | # where there are no such tags. Also note that file descriptor 9 20 | # is reserved for input from the test script, and file descriptor 8 21 | # preserves the original stdout. Option settings are preserved between the 22 | # execution of different code chunks; initially, all standard zsh options 23 | # (the effect of `emulate -R zsh') are set. 24 | 25 | %prep 26 | # This optional section prepares the test, creating directories and files 27 | # and so on. Chunks of code are separated by blank lines (which is not 28 | # necessary before the end of the section); each chunk of code is evaluated 29 | # in one go and must return status 0, or the preparation is deemed to have 30 | # failed and the test ends with an appropriate error message. Standard 31 | # output from this section is redirected to /dev/null, but standard error 32 | # is not redirected. 33 | # 34 | # Tests should use subdirectories ending in `.tmp'. These will be 35 | # removed with all the contents even if the test is aborted. 36 | mkdir cdtst.tmp cdtst.tmp/real cdtst.tmp/sub 37 | 38 | ln -s ../real cdtst.tmp/sub/fake 39 | 40 | setopt chaselinks 41 | cd . 42 | unsetopt chaselinks 43 | mydir=$PWD 44 | 45 | %test 46 | # This is where the tests are run. It consists of blocks separated 47 | # by blank lines. Each block has the same format and there may be any 48 | # number of them. It consists of indented code, plus optional sets of lines 49 | # beginning '<', '>' and '?' which may appear in any order. These correspond 50 | # to stdin (fed to the code), stdout (compared with code output) and 51 | # stderr (compared with code error output) respectively. These subblocks 52 | # may occur in any order, but the natural one is: code, stdin, stdout, 53 | # stderr. 54 | # 55 | # The rules for '<', '>' and '?' lines are the same: only the first 56 | # character is stripped (with the excpetion for '*' noted below), with 57 | # subsequent whitespace being significant; lines are not subject to any 58 | # substitution unless the `q' flag (see below) is set. 59 | # 60 | # Each line of a '>' and '?' chunk may be preceded by a '*', so the line 61 | # starts '*>' or '*?'. This signifies that for any line with '*' in front 62 | # the actual output should be pattern matched against the corresponding 63 | # lines in the test output. Each line following '>' or '?' must be a 64 | # valid pattern, so characters special to patterns such as parentheses 65 | # must be quoted with a backslash. The EXTENDED_GLOB option is used for 66 | # all such patterns. 67 | # 68 | # Each chunk of indented code is to be evaluated in one go and is to 69 | # be followed by a line starting (in the first column) with 70 | # the expected status returned by the code when run, or - if it is 71 | # irrelevant. An optional set of single-letter flags follows the status 72 | # or -. The following are understood: 73 | # . d Don't diff stdout against the expected stdout. 74 | # D Don't diff stderr against the expected stderr. 75 | # q All redirection lines given in the test script (not the lines 76 | # actually produced by the test) are subject to ordinary quoted shell 77 | # expansion (i.e. not globbing). 78 | # This can be followed by a `:' and a message describing the 79 | # test, which will be printed if the test fails, along with a 80 | # description of the failure that occurred. The `:' and message are 81 | # optional, but highly recommended. 82 | # Hence a complete status line looks something like: 83 | # 0dDq:Checking whether the world will end with a bang or a whimper 84 | # 85 | # If either or both of the '>' and '?' sets of lines is absent, it is 86 | # assumed the corresponding output should be empty and it is an error if it 87 | # is not. If '<' is empty, stdin is an empty (but opened) file. 88 | # 89 | # It is also possible to add lines in the redirection section beginning 90 | # with `F:'. The remaining text on all such lines will be concatenated 91 | # (with newlines in between) and displayed in the event of an error. 92 | # This text is useful for explaining certain frequent errors, for example 93 | # ones which may arise from the environment rather than from the shell 94 | # itself. (The example below isn't particularly useful as errors with 95 | # `cd' are unusual.) 96 | # 97 | # A couple of features aren't used in this file, but are usefuil in cases 98 | # where features may not be available so should not be tested. They boh 99 | # take the form of variables. Note that to keep the test framework simple 100 | # there is no magic in setting the variables: the chunk of code being 101 | # executed needs to avoid executing any test code by appropriate structure 102 | # (typically "if"). In both cases, the value of the variable is output 103 | # as a warning that the test was skipped. 104 | # ZTST_unimplemented: Set this in the %prep phase if the entire test file 105 | # is to be skipped. 106 | # ZTST_skip: Set this in any test case if that single test case is to be 107 | # skipped. Testing resumes at the next test case in the same file. 108 | cd cdtst.tmp/sub/fake && 109 | pwd && 110 | print $PWD 111 | 0q:Preserving symbolic links in the current directory string 112 | >$mydir/cdtst.tmp/sub/fake 113 | >$mydir/cdtst.tmp/sub/fake 114 | F:This test shouldn't really fail. The fact that it has indicates 115 | F:something is broken. But you already knew that. 116 | 117 | cd ../../.. && 118 | pwd && 119 | print $PWD 120 | 0q:Changing directory up through symbolic links without following them 121 | >$mydir 122 | >$mydir 123 | 124 | setopt chaselinks 125 | cd cdtst.tmp/sub/fake && 126 | pwd && 127 | print $PWD 128 | 0q:Resolving symbolic links with chaselinks set 129 | >$mydir/cdtst.tmp/real 130 | >$mydir/cdtst.tmp/real 131 | 132 | ln -s nonexistent link_to_nonexistent 133 | pwd1=$(pwd -P) 134 | cd -s link_to_nonexistent 135 | pwd2=$(pwd -P) 136 | [[ $pwd1 = $pwd2 ]] || print "Ooops, changed to directory '$pwd2'" 137 | 0: 138 | ?(eval):cd:3: not a directory: link_to_nonexistent 139 | 140 | %clean 141 | # This optional section cleans up after the test, if necessary, 142 | # e.g. killing processes etc. This is in addition to the removal of *.tmp 143 | # subdirectories. This is essentially like %prep, except that status 144 | # return values are ignored. 145 | -------------------------------------------------------------------------------- /Test/B04read.ztst: -------------------------------------------------------------------------------- 1 | # Tests for the read builtin 2 | 3 | # Tested elsewhere: 4 | # reading from a coprocess A01grammar, A04redirect 5 | 6 | # Not tested: 7 | # -c/-l/-n (options for compctl functions) 8 | # -q/-s (needs a tty) 9 | 10 | %test 11 | 12 | read <<<'hello world' 13 | print $REPLY 14 | 0:basic read command 15 | >hello world 16 | 17 | read -A <<<'hello world' 18 | print $reply[2] 19 | 0:array read 20 | >world 21 | 22 | read -k3 -u0 <<foo 26 | 27 | for char in y Y n N X $'\n'; do 28 | read -q -u0 <<<$char 29 | print $? 30 | done 31 | 0:read yes or no, default no 32 | >0 33 | >0 34 | >1 35 | >1 36 | >1 37 | >1 38 | 39 | read -d: <<foo 43 | 44 | print foo:bar|IFS=: read -A 45 | print $reply 46 | 0:use different, IFS separator to array 47 | >foo bar 48 | 49 | print -z hello world; read -z 50 | print $REPLY 51 | 0:read from editor buffer stack 52 | >hello world 53 | 54 | unset REPLY 55 | read -E <<hello 59 | >hello 60 | 61 | unset REPLY 62 | read -e <<hello 66 | > 67 | 68 | read -e -t <<hello 71 | 72 | SECONDS=0 73 | read -e -t 5 <<hello 77 | >0 78 | 79 | print -n 'Testing the\0null hypothesis\0' | 80 | while read -d $'\0' line; do print $line; done 81 | 0:read with null delimiter 82 | >Testing the 83 | >null hypothesis 84 | 85 | # Note that trailing NULLs are not stripped even if they are in 86 | # $IFS; only whitespace characters contained in $IFS are stripped. 87 | print -n $'Aaargh, I hate nulls.\0\0\0' | read line 88 | print ${#line} 89 | 0:read with trailing metafied characters 90 | >24 91 | 92 | (typeset -r foo 93 | read foo) <<one 101 | >two 102 | >three 103 | >one:two:three 104 | 105 | array=() 106 | read -Ae array <<<'four five six' 107 | print ${(j.:.)array} 108 | 0:Behaviour of -A and -e combination 109 | >four 110 | >five 111 | >six 112 | > 113 | -------------------------------------------------------------------------------- /Test/B05eval.ztst: -------------------------------------------------------------------------------- 1 | # Tests for the eval builtin. 2 | # This is quite short; eval is widely tested throughout the test suite 3 | # and its basic behaviour is fairly straightforward. 4 | 5 | %prep 6 | 7 | cmd='print $?' 8 | 9 | %test 10 | 11 | false 12 | eval $cmd 13 | 0:eval retains value of $? 14 | >1 15 | 16 | # no point getting worked up over what the error message is... 17 | ./command_not_found 2>/dev/null 18 | eval $cmd 19 | 0:eval after command not found 20 | >127 21 | 22 | # trick the test system 23 | sp= 24 | false 25 | eval " 26 | $sp 27 | $sp 28 | $sp 29 | " 30 | 0:eval with empty command resets the status 31 | 32 | false 33 | eval 34 | 0:eval with empty command resets the status 35 | -------------------------------------------------------------------------------- /Test/B06fc.ztst: -------------------------------------------------------------------------------- 1 | # Tests of fc command 2 | %prep 3 | 4 | mkdir fc.tmp 5 | cd fc.tmp 6 | print 'fc -l foo' >fcl 7 | 8 | %test 9 | $ZTST_testdir/../Src/zsh -f ./fcl 10 | 1:Checking that fc -l foo doesn't core dump when history is empty 11 | ?./fcl:fc:1: event not found: foo 12 | 13 | PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:' 14 | 0:Checking that fc -p doesn't core dump when history size is zero 15 | *?*%* 16 | 17 | PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0' 18 | 1:Checking that fc -p rejects non-integer history size 19 | *?*% fc: HISTSIZE must be an integer 20 | *?*%* 21 | 22 | PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a' 23 | 1:Checking that fc -p rejects non-integer history save size 24 | *?*% fc: SAVEHIST must be an integer 25 | *?*%* 26 | -------------------------------------------------------------------------------- /Test/B07emulate.ztst: -------------------------------------------------------------------------------- 1 | # Test the "emulate" builtin and related functions. 2 | 3 | %prep 4 | 5 | isset() { 6 | print -n "${1}: " 7 | if [[ -o $1 ]]; then print yes; else print no; fi 8 | } 9 | showopts() { 10 | # Set for Bourne shell emulation 11 | isset shwordsplit 12 | # Set in native mode and unless "emulate -R" is in use 13 | isset banghist 14 | } 15 | cshowopts() { 16 | showopts 17 | # Show a csh option, too 18 | isset cshnullglob 19 | } 20 | 21 | %test 22 | 23 | (print Before 24 | showopts 25 | fn() { 26 | emulate sh 27 | } 28 | fn 29 | print After 30 | showopts) 31 | 0:Basic use of emulate 32 | >Before 33 | >shwordsplit: no 34 | >banghist: yes 35 | >After 36 | >shwordsplit: yes 37 | >banghist: yes 38 | 39 | fn() { 40 | emulate -L sh 41 | print During 42 | showopts 43 | } 44 | print Before 45 | showopts 46 | fn 47 | print After 48 | showopts 49 | 0:Use of emulate -L 50 | >Before 51 | >shwordsplit: no 52 | >banghist: yes 53 | >During 54 | >shwordsplit: yes 55 | >banghist: yes 56 | >After 57 | >shwordsplit: no 58 | >banghist: yes 59 | 60 | (print Before 61 | showopts 62 | emulate -R sh 63 | print After 64 | showopts) 65 | 0:Use of emulate -R 66 | >Before 67 | >shwordsplit: no 68 | >banghist: yes 69 | >After 70 | >shwordsplit: yes 71 | >banghist: no 72 | 73 | print Before 74 | showopts 75 | emulate sh -c 'print During; showopts' 76 | print After 77 | showopts 78 | 0:Use of emulate -c 79 | >Before 80 | >shwordsplit: no 81 | >banghist: yes 82 | >During 83 | >shwordsplit: yes 84 | >banghist: yes 85 | >After 86 | >shwordsplit: no 87 | >banghist: yes 88 | 89 | print Before 90 | showopts 91 | emulate -R sh -c 'print During; showopts' 92 | print After 93 | showopts 94 | 0:Use of emulate -R -c 95 | >Before 96 | >shwordsplit: no 97 | >banghist: yes 98 | >During 99 | >shwordsplit: yes 100 | >banghist: no 101 | >After 102 | >shwordsplit: no 103 | >banghist: yes 104 | 105 | print Before 106 | showopts 107 | emulate -R sh -c 'shshowopts() { showopts; }' 108 | print After definition 109 | showopts 110 | print In sticky emulation 111 | shshowopts 112 | print After sticky emulation 113 | showopts 114 | 0:Basic sticky function emulation 115 | >Before 116 | >shwordsplit: no 117 | >banghist: yes 118 | >After definition 119 | >shwordsplit: no 120 | >banghist: yes 121 | >In sticky emulation 122 | >shwordsplit: yes 123 | >banghist: no 124 | >After sticky emulation 125 | >shwordsplit: no 126 | >banghist: yes 127 | 128 | print Before 129 | cshowopts 130 | emulate -R sh -c 'shshowopts() { cshowopts; }' 131 | emulate csh -c 'cshshowopts() { 132 | cshowopts 133 | print In nested sh emulation 134 | shshowopts 135 | }' 136 | print After definition 137 | cshowopts 138 | print In sticky csh emulation 139 | cshshowopts 140 | print After sticky emulation 141 | cshowopts 142 | 0:Basic sticky function emulation 143 | >Before 144 | >shwordsplit: no 145 | >banghist: yes 146 | >cshnullglob: no 147 | >After definition 148 | >shwordsplit: no 149 | >banghist: yes 150 | >cshnullglob: no 151 | >In sticky csh emulation 152 | >shwordsplit: no 153 | >banghist: yes 154 | >cshnullglob: yes 155 | >In nested sh emulation 156 | >shwordsplit: yes 157 | >banghist: no 158 | >cshnullglob: no 159 | >After sticky emulation 160 | >shwordsplit: no 161 | >banghist: yes 162 | >cshnullglob: no 163 | 164 | isalp() { if [[ -o alwayslastprompt ]]; then print on; else print off; fi; } 165 | emulate sh -c 'shfunc_inner() { setopt alwayslastprompt; }' 166 | emulate csh -c 'cshfunc_inner() { setopt alwayslastprompt; }' 167 | emulate sh -c 'shfunc_outer() { 168 | unsetopt alwayslastprompt; 169 | shfunc_inner; 170 | isalp 171 | unsetopt alwayslastprompt 172 | cshfunc_inner 173 | isalp 174 | }' 175 | shfunc_outer 176 | 0:Sticky emulation not triggered if sticky emulation unchanged 177 | >on 178 | >off 179 | 180 | ( 181 | setopt ignorebraces 182 | emulate zsh -o extendedglob -c ' 183 | [[ -o ignorebraces ]] || print "Yay, ignorebraces was reset" 184 | [[ -o extendedglob ]] && print "Yay, extendedglob is set" 185 | ' 186 | ) 187 | 0:emulate -c with options 188 | >Yay, ignorebraces was reset 189 | >Yay, extendedglob is set 190 | 191 | ( 192 | setopt ignorebraces 193 | emulate zsh -o extendedglob 194 | [[ -o ignorebraces ]] || print "Yay, ignorebraces is no longer set" 195 | [[ -o extendedglob ]] && print "Yay, extendedglob is set" 196 | ) 197 | 0:emulate with options but no -c 198 | >Yay, ignorebraces is no longer set 199 | >Yay, extendedglob is set 200 | 201 | emulate zsh -o fixallmybugs 'print This was executed, bad' 202 | 1:emulate -c with incorrect options 203 | ?(eval):emulate:1: no such option: fixallmybugs 204 | 205 | emulate zsh -c ' 206 | func() { [[ -o extendedglob ]] || print extendedglob is off } 207 | ' 208 | func 209 | emulate zsh -o extendedglob -c ' 210 | func() { [[ -o extendedglob ]] && print extendedglob is on } 211 | ' 212 | func 213 | 0:options specified alongside emulation are also sticky 214 | >extendedglob is off 215 | >extendedglob is on 216 | 217 | emulate zsh -o extendedglob -c ' 218 | func_inner() { setopt nobareglobqual } 219 | ' 220 | emulate zsh -o extendedglob -c ' 221 | func_outer() { 222 | func_inner 223 | [[ -o bareglobqual ]] || print bareglobqual was turned off 224 | [[ -o extendedglob ]] && print extendedglob is on, though 225 | } 226 | ' 227 | [[ -o extendedglob ]] || print extendedglob is initially off 228 | func_outer 229 | 0:options propagate between identical emulations 230 | >extendedglob is initially off 231 | >bareglobqual was turned off 232 | >extendedglob is on, though 233 | 234 | emulate zsh -o extendedglob -c ' 235 | func_inner() { setopt nobareglobqual } 236 | ' 237 | emulate zsh -o extendedglob -o cbases -c ' 238 | func_outer() { 239 | func_inner 240 | [[ -o bareglobqual ]] && print bareglobqual is still on 241 | [[ -o extendedglob ]] && print extendedglob is on, too 242 | } 243 | ' 244 | [[ -o extendedglob ]] || print extendedglob is initially off 245 | func_outer 246 | 0:options do not propagate between different emulations 247 | >extendedglob is initially off 248 | >bareglobqual is still on 249 | >extendedglob is on, too 250 | 251 | emulate sh -c '[[ a == a ]]' 252 | 0:regression test for POSIX_ALIASES reserved words 253 | F:Some reserved tokens are handled in alias expansion 254 | -------------------------------------------------------------------------------- /Test/B08shift.ztst: -------------------------------------------------------------------------------- 1 | # Test the shift builtin. 2 | 3 | %test 4 | 5 | set -- one two three four five six seven eight nine ten 6 | shift 7 | print $* 8 | shift 2 9 | print $* 10 | shift -p 3 11 | print $* 12 | shift -p 13 | print $* 14 | 0:shifting positional parameters 15 | >two three four five six seven eight nine ten 16 | >four five six seven eight nine ten 17 | >four five six seven 18 | >four five six 19 | 20 | array=(yan tan tether mether pip azer sezar akker conter dick) 21 | shift 2 array 22 | print $array 23 | shift array 24 | print $array 25 | shift -p 3 array 26 | print $array 27 | shift -p array 28 | print $array 29 | 0:shifting array 30 | >tether mether pip azer sezar akker conter dick 31 | >mether pip azer sezar akker conter dick 32 | >mether pip azer sezar 33 | >mether pip azer 34 | -------------------------------------------------------------------------------- /Test/B09hash.ztst: -------------------------------------------------------------------------------- 1 | # The hash builtin is most used for the command hash table, which is 2 | # populated automatically. This is therefore highly system specific, 3 | # so mostly we'll test with the directory hash table: the logic is 4 | # virtually identical but with the different table, and furthermore 5 | # the shell doesn't care whether the directory exists unless you refer 6 | # to it in a context that needs one. 7 | 8 | %prep 9 | populate_hash() { 10 | hash -d one=/first/directory 11 | hash -d two=/directory/the/second 12 | hash -d three=/noch/ein/verzeichnis 13 | hash -d four=/bored/with/this/now 14 | } 15 | 16 | %test 17 | 18 | hash -d 19 | 0:Directory hash initially empty 20 | 21 | populate_hash 22 | hash -d 23 | 0:Populating directory hash and output with sort 24 | >four=/bored/with/this/now 25 | >one=/first/directory 26 | >three=/noch/ein/verzeichnis 27 | >two=/directory/the/second 28 | 29 | hash -rd 30 | hash -d 31 | 0:Empty hash 32 | 33 | populate_hash 34 | hash -d 35 | 0:Refill hash 36 | >four=/bored/with/this/now 37 | >one=/first/directory 38 | >three=/noch/ein/verzeichnis 39 | >two=/directory/the/second 40 | 41 | hash -dL 42 | 0:hash -L option 43 | >hash -d four=/bored/with/this/now 44 | >hash -d one=/first/directory 45 | >hash -d three=/noch/ein/verzeichnis 46 | >hash -d two=/directory/the/second 47 | 48 | hash -dm 't*' 49 | 0:hash -m option 50 | >three=/noch/ein/verzeichnis 51 | >two=/directory/the/second 52 | 53 | hash -d five=/yet/more six=/here/we/go seven=/not/yet/eight 54 | hash -d 55 | 0:Multiple assignments 56 | >five=/yet/more 57 | >four=/bored/with/this/now 58 | >one=/first/directory 59 | >seven=/not/yet/eight 60 | >six=/here/we/go 61 | >three=/noch/ein/verzeichnis 62 | >two=/directory/the/second 63 | 64 | hash -d one two three 65 | 0:Multiple arguments with no assignment not in verbose mode 66 | 67 | hash -vd one two three 68 | 0:Multiple arguments with no assignment in verbose mode 69 | >one=/first/directory 70 | >two=/directory/the/second 71 | >three=/noch/ein/verzeichnis 72 | 73 | hash -d t-t=/foo 74 | i="~t-t" 75 | print ~t-t/bar 76 | print ${~i}/rab 77 | 0:Dashes are untokenized in directory hash names 78 | >/foo/bar 79 | >/foo/rab 80 | -------------------------------------------------------------------------------- /Test/C05debug.ztst: -------------------------------------------------------------------------------- 1 | %prep 2 | 3 | setopt localtraps 4 | 5 | %test 6 | 7 | unsetopt DEBUG_BEFORE_CMD 8 | debug-trap-bug1() { 9 | setopt localtraps 10 | print "print bug file here" >bug-file 11 | print "print this is line one 12 | print this is line two 13 | print this is line three 14 | print and this is line fifty-nine." >bug-file2 15 | function debug_trap_handler { 16 | print $functrace[1] 17 | do_bug 18 | } 19 | function do_bug { 20 | . ./bug-file 21 | } 22 | trap 'echo EXIT hit' EXIT 23 | trap 'debug_trap_handler' DEBUG 24 | . ./bug-file2 25 | } 26 | debug-trap-bug1 27 | 0: Relationship between traps and sources 28 | >debug-trap-bug1:15 29 | >bug file here 30 | >this is line one 31 | >./bug-file2:1 32 | >bug file here 33 | >this is line two 34 | >./bug-file2:2 35 | >bug file here 36 | >this is line three 37 | >./bug-file2:3 38 | >bug file here 39 | >and this is line fifty-nine. 40 | >./bug-file2:4 41 | >bug file here 42 | >debug-trap-bug1:16 43 | >bug file here 44 | >EXIT hit 45 | 46 | cat >zsh-trapreturn-bug2 <<-'HERE' 47 | cmd='./fdasfsdafd' 48 | [[ -x $cmd ]] && rm $cmd 49 | set -o DEBUG_BEFORE_CMD 50 | trap '[[ $? -ne 0 ]] && exit 0' DEBUG 51 | $cmd # invalid command 52 | # Failure 53 | exit 10 54 | HERE 55 | $ZTST_testdir/../Src/zsh -f ./zsh-trapreturn-bug2 2>erroutput.dif 56 | mystat=$? 57 | ( 58 | setopt extendedglob 59 | print ${"$(< erroutput.dif)"%%:[^:]#: ./fdasfsdafd} 60 | ) 61 | (( mystat == 0 )) 62 | 0: trapreturn handling bug is properly fixed 63 | >./zsh-trapreturn-bug2:5 64 | 65 | fn() { 66 | setopt localtraps localoptions debugbeforecmd 67 | trap '(( LINENO == 4 )) && setopt errexit' DEBUG 68 | print $LINENO three 69 | print $LINENO four 70 | print $LINENO five 71 | [[ -o errexit ]] && print "Hey, ERREXIT is set!" 72 | } 73 | fn 74 | 1:Skip line from DEBUG trap 75 | >3 three 76 | >5 five 77 | 78 | # Assignments are a special case, since they use a simpler 79 | # wordcode type, so we need to test skipping them separately. 80 | fn() { 81 | setopt localtraps localoptions debugbeforecmd 82 | trap '(( LINENO == 4 )) && setopt errexit' DEBUG 83 | x=three 84 | x=four 85 | print $LINENO $x 86 | [[ -o errexit ]] && print "Hey, ERREXIT is set!" 87 | } 88 | fn 89 | 1:Skip assignment from DEBUG trap 90 | >5 three 91 | 92 | fn() { 93 | setopt localtraps localoptions debugbeforecmd 94 | trap 'print $LINENO' DEBUG 95 | [[ a = a ]] && print a is ok 96 | } 97 | fn 98 | 0:line numbers of complex sublists 99 | >3 100 | >a is ok 101 | 102 | fn() { 103 | setopt localtraps localoptions debugbeforecmd 104 | trap 'print $LINENO' DEBUG 105 | print before 106 | x=' first 107 | second 108 | third' 109 | print $x 110 | } 111 | fn 112 | 0:line numbers of multiline assignments 113 | >3 114 | >before 115 | >4 116 | >7 117 | > first 118 | > second 119 | > third 120 | 121 | fn() { 122 | emulate -L zsh; setopt debugbeforecmd 123 | trap 'print "$LINENO: '\''$ZSH_DEBUG_CMD'\''"' DEBUG 124 | print foo && 125 | print bar || 126 | print rod 127 | x=y 128 | print $x 129 | fn2() { echo wow } 130 | fn2 131 | } 132 | fn 133 | 0:ZSH_DEBUG_CMD in debug traps 134 | >3: 'print foo && print bar || print rod' 135 | >foo 136 | >bar 137 | >6: 'x=y ' 138 | >7: 'print $x' 139 | >y 140 | >8: 'fn2 () { 141 | > echo wow 142 | >}' 143 | >9: 'fn2' 144 | >0: 'echo wow' 145 | >wow 146 | 147 | foo() { 148 | emulate -L zsh; setopt debugbeforecmd 149 | trap '[[ $ZSH_DEBUG_CMD == *bar* ]] && return 2' DEBUG 150 | echo foo 151 | echo bar 152 | } 153 | foo 154 | 2:Status of forced return from eval-style DEBUG trap 155 | >foo 156 | 157 | %clean 158 | 159 | rm -f bug-file bug-file2 erroutput.dif zsh-trapreturn-bug2 160 | -------------------------------------------------------------------------------- /Test/D01prompt.ztst: -------------------------------------------------------------------------------- 1 | %prep 2 | 3 | mkdir prompt.tmp 4 | cd prompt.tmp 5 | mydir=$PWD 6 | SHLVL=2 7 | setopt extendedglob 8 | 9 | %test 10 | 11 | hash -d mydir=$mydir 12 | print -P ' %%%): %) 13 | %%~: %~ 14 | %%d: %d 15 | %%1/: %1/ 16 | %%h: %h 17 | %%L: %L 18 | %%M: %M 19 | %%m: %m 20 | %%n: %n 21 | %%N: %N 22 | %%i: %i 23 | a%%{...%%}b: a%{%}b 24 | ' 25 | 0q:Basic prompt escapes as shown. 26 | > %): ) 27 | > %~: ~mydir 28 | > %d: $mydir 29 | > %1/: ${mydir:t} 30 | > %h: 0 31 | > %L: 2 32 | > %M: $HOST 33 | > %m: ${HOST%%.*} 34 | > %n: $USERNAME 35 | > %N: (eval) 36 | > %i: 2 37 | > a%{...%}b: ab 38 | > 39 | 40 | true 41 | print -P '%?' 42 | false 43 | print -P '%?' 44 | 0:`%?' prompt escape 45 | >0 46 | >1 47 | 48 | PS4="%_> " 49 | setopt xtrace 50 | if true; then true; else false; fi 51 | unsetopt xtrace 52 | 0:`%_' prompt escape 53 | ?if> true 54 | ?then> true 55 | ?> unsetopt xtrace 56 | 57 | diff =(print -P '%#') =(print -P '%(!.#.%%)') 58 | 0:`%#' prompt escape and its equivalent 59 | 60 | psvar=(caesar adsum jam forte) 61 | print -P '%v' '%4v' 62 | 0:`%v' prompt escape 63 | >caesar forte 64 | 65 | true 66 | print -P '%(?.true.false)' 67 | false 68 | print -P '%(?.true.false)' 69 | 0:ternary prompt escapes 70 | >true 71 | >false 72 | 73 | print -P 'start %10<......>truncated at 10%>> Not truncated%3> ...>Not shown' 75 | 0:prompt truncation 76 | >start ...d at 10 Not truncated ... 77 | >start truncat... Not truncated ... 78 | 79 | # It's hard to check the time and date as they are moving targets. 80 | # We therefore just check that various forms of the date are consistent. 81 | # In fact, if you perform this at midnight it can still fail. 82 | # We could test for that, but we can't be bothered. 83 | # I hope LC_ALL is enough to make the format what's expected. 84 | 85 | LC_ALL=C 86 | date1=$(print -P %w) 87 | date2=$(print -P %W) 88 | date3=$(print -P %D) 89 | if [[ $date1 != [A-Z][a-z][a-z][[:blank:]]##[0-9]## ]]; then 90 | print "Date \`$date1' is not in the form \`Day DD' (e.g. \`Mon 1'" 91 | fi 92 | if [[ $date2 != [0-9][0-9]/[0-9][0-9]/[0-9][0-9] ]]; then 93 | print "Date \`$date2' is not in the form \`DD/MM/YYYY'" 94 | fi 95 | if [[ $date3 != [0-9][0-9]-[0-9][0-9]-[0-9][0-9] ]]; then 96 | print "Date \`$date3' is not in the form \`YY-MM-DD'" 97 | fi 98 | if (( $date1[5,-1] != $date2[4,5] )) || (( $date2[4,5] != $date3[7,8] )) 99 | then 100 | print "Days of month do not agree in $date1, $date2, $date3" 101 | fi 102 | if (( $date2[1,2] != $date3[4,5] )); then 103 | print "Months do not agree in $date2, $date3" 104 | fi 105 | if (( $date2[7,8] != $date3[1,2] )); then 106 | print "Years do not agree in $date2, $date3" 107 | fi 108 | 0:Dates produced by prompt escapes 109 | 110 | mkdir foo 111 | mkdir foo/bar 112 | mkdir foo/bar/rod 113 | (zsh_directory_name() { 114 | emulate -L zsh 115 | setopt extendedglob 116 | local -a match mbegin mend 117 | if [[ $1 = d ]]; then 118 | if [[ $2 = (#b)(*bar)/rod ]]; then 119 | reply=(barmy ${#match[1]}) 120 | else 121 | return 1 122 | fi 123 | else 124 | if [[ $2 = barmy ]]; then 125 | reply=($mydir/foo/bar) 126 | else 127 | return 1 128 | fi 129 | fi 130 | } 131 | # success 132 | print ~[barmy]/anything 133 | cd foo/bar/rod 134 | print -P %~ 135 | # failure 136 | setopt nonomatch 137 | print ~[scuzzy]/rubbish 138 | cd ../.. 139 | print -P %~ 140 | # catastrophic failure 141 | unsetopt nonomatch 142 | print ~[scuzzy]/rubbish 143 | ) 144 | 1q:Dynamic named directories 145 | >$mydir/foo/bar/anything 146 | >~[barmy]/rod 147 | >~[scuzzy]/rubbish 148 | >~mydir/foo 149 | ?(eval):33: no directory expansion: ~[scuzzy] 150 | 151 | ( 152 | zsh_directory_name() { 153 | emulate -L zsh 154 | setopt extendedglob 155 | local -a match mbegin mend 156 | if [[ $1 = n ]]; then 157 | if [[ $2 = *:l ]]; then 158 | reply=(${2%%:l}/very_long_directory_name) 159 | return 0 160 | else 161 | return 1 162 | fi 163 | else 164 | if [[ $2 = (#b)(*)/very_long_directory_name ]]; then 165 | reply=(${match[1]}:l ${#2}) 166 | return 0 167 | else 168 | return 1 169 | fi 170 | fi 171 | } 172 | parent=$PWD 173 | dir=$parent/very_long_directory_name 174 | mkdir $dir 175 | cd $dir 176 | fn() { 177 | PS4='+%N:%i> ' 178 | setopt localoptions xtrace 179 | # The following is the key to the test. 180 | # It invokes zsh_directory_name which does PS4 output stuff 181 | # while we're doing prompt handling for the parameter 182 | # substitution. This checks recursion works OK. 183 | local d=${(%):-%~} 184 | print ${d//$parent/\} 185 | } 186 | fn 2>stderr 187 | # post process error to remove variable contents 188 | while read line; do 189 | # tricky: reply is set to include directory length which is variable 190 | [[ $line = *reply* ]] && continue 191 | print ${line//$parent/\} 192 | done &2 193 | ) 194 | 0:Recursive use of prompts 195 | >~[:l] 196 | ?+zsh_directory_name:1> emulate -L zsh 197 | ?+zsh_directory_name:2> setopt extendedglob 198 | ?+zsh_directory_name:3> local -a match mbegin mend 199 | ?+zsh_directory_name:4> [[ d = n ]] 200 | ?+zsh_directory_name:12> [[ /very_long_directory_name = (#b)(*)/very_long_directory_name ]] 201 | ?+zsh_directory_name:14> return 0 202 | ?+fn:7> local d='~[:l]' 203 | ?+fn:8> print '~[:l]' 204 | -------------------------------------------------------------------------------- /Test/D02glob.ztst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-shell/zpmod/e1c5aabc69f09103971020d6de8c1fad722a3946/Test/D02glob.ztst -------------------------------------------------------------------------------- /Test/D03procsubst.ztst: -------------------------------------------------------------------------------- 1 | # Tests for process substitution: <(...), >(...) and =(...). 2 | 3 | %prep 4 | if grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h > /dev/null 2>&1 || 5 | grep '#define HAVE_FIFOS' $ZTST_testdir/../config.h > /dev/null 2>&1; then 6 | mkdir procsubst.tmp 7 | cd procsubst.tmp 8 | print 'First\tSecond\tThird\tFourth' >FILE1 9 | print 'Erste\tZweite\tDritte\tVierte' >FILE2 10 | else 11 | ZTST_unimplemented="process substitution is not supported" 12 | true 13 | fi 14 | 15 | function copycat { cat "$@" } 16 | 17 | %test 18 | paste <(cut -f1 FILE1) <(cut -f3 FILE2) 19 | 0:<(...) substitution 20 | >First Dritte 21 | 22 | # slightly desperate hack to force >(...) to be synchronous 23 | { paste <(cut -f2 FILE1) <(cut -f4 FILE2) } > >(sed 's/e/E/g' >OUTFILE) 24 | cat OUTFILE 25 | 0:>(...) substitution 26 | >SEcond ViErtE 27 | 28 | diff =(cat FILE1) =(cat FILE2) 29 | 1:=(...) substituion 30 | >1c1 31 | >< First Second Third Fourth 32 | >--- 33 | >> Erste Zweite Dritte Vierte 34 | 35 | copycat <(print First) <(print Zweite) 36 | 0:FDs remain open for external commands called from functions 37 | >First 38 | >Zweite 39 | 40 | catfield2() { 41 | local -a args 42 | args=(${(s.,.)1}) 43 | print $args[1] 44 | cat $args[2] 45 | print $args[3] 46 | } 47 | catfield2 up,<(print $'\x64'own),sideways 48 | 0:<(...) when embedded within an argument 49 | >up 50 | >down 51 | >sideways 52 | 53 | outputfield2() { 54 | local -a args 55 | args=(${(s.,.)1}) 56 | print $args[1] 57 | echo 'How sweet the moonlight sits upon the bank' >$args[2] 58 | print $args[3] 59 | } 60 | outputfield2 muddy,>(sed -e s/s/th/g >outputfield2.txt),vesture 61 | # yuk 62 | while [[ ! -e outputfield2.txt || ! -s outputfield2.txt ]]; do :; done 63 | cat outputfield2.txt 64 | 0:>(...) when embedded within an argument 65 | >muddy 66 | >vesture 67 | >How thweet the moonlight thitth upon the bank 68 | 69 | catfield1() { 70 | local -a args 71 | args=(${(s.,.)1}) 72 | cat $args[1] 73 | print $args[2] 74 | } 75 | catfield1 =(echo s$'\x69't),jessica 76 | 0:=(...) followed by something else without a break 77 | >sit 78 | >jessica 79 | 80 | ( 81 | setopt nonomatch 82 | # er... why is this treated as a glob? 83 | print everything,=(here is left),alone 84 | ) 85 | 0:=(...) preceded by other stuff has no special effect 86 | >everything,=(here is left),alone 87 | 88 | print something=${:-=(echo 'C,D),(F,G)'} 89 | 1: Graceful handling of bad substitution in enclosed context 90 | ?(eval):1: unterminated `=(...)' 91 | # '` 92 | 93 | () { 94 | print -n "first: " 95 | cat $1 96 | print -n "second: " 97 | cat $2 98 | } =(echo This becomes argument one) =(echo and this argument two) 99 | function { 100 | print -n "third: " 101 | cat $1 102 | print -n "fourth: " 103 | cat $2 104 | } =(echo This becomes argument three) =(echo and this argument four) 105 | 0:Process environment of anonymous functions 106 | >first: This becomes argument one 107 | >second: and this argument two 108 | >third: This becomes argument three 109 | >fourth: and this argument four 110 | 111 | () { 112 | # Make sure we don't close the file descriptor too early 113 | eval 'print "Execute a complicated command first" | sed s/command/order/' 114 | cat $1 115 | } <(echo This line was brought to you by the letters F and D) 116 | 0:Process substitution as anonymous function argument 117 | >Execute a complicated order first 118 | >This line was brought to you by the letters F and D 119 | 120 | alias foo='cat <(' 121 | eval 'foo echo this is bound to work)' 122 | 0:backtacking within command string parsing with alias still pending 123 | >this is bound to work 124 | 125 | alias foo='cat <( print' 126 | eval 'foo here is some output)' 127 | 0:full alias expanded when substitution starts in alias 128 | >here is some output 129 | 130 | if ! (mkfifo test_pipe >/dev/null 2>&1); then 131 | ZTST_skip="mkfifo not available" 132 | else 133 | echo 1 | tee >(cat > test_pipe) | (){ 134 | local pipein 135 | read pipein 1 143 | >1 144 | 145 | if [[ ! -e test_pipe ]]; then 146 | ZTST_skip="mkfifo not available" 147 | else 148 | echo 1 | tee >(cat > test_pipe) | paste - test_pipe 149 | fi 150 | 0:proc subst fd in forked subshell closed in parent (external command) 151 | >1 1 152 | -------------------------------------------------------------------------------- /Test/D05array.ztst: -------------------------------------------------------------------------------- 1 | # Tests for array indexing 2 | 3 | %prep 4 | 5 | foo=(a b c d e f g) 6 | arr=(foo bar baz) 7 | mkdir array.tmp 8 | touch array.tmp/{1..9} 9 | 10 | %test 11 | 12 | echo .$foo[1]. 13 | 0:The first element 14 | >.a. 15 | 16 | echo .$foo[1,4]. 17 | 0:Normal multi-item indexing 18 | >.a b c d. 19 | 20 | echo .$foo[1,0]. 21 | 0:This should be empty 22 | >.. 23 | 24 | echo .$foo[4,1]. 25 | 0:Another empty slice 26 | >.. 27 | 28 | echo .$foo[1,-8]. 29 | 0:An empty slice with a negative end 30 | >.. 31 | 32 | echo .$foo[0]. 33 | 0:Treat 0 as empty 34 | >.. 35 | 36 | echo .$foo[0,0]. 37 | 0:Treat 0,0 as empty 38 | >.. 39 | 40 | echo .$foo[0,1]. 41 | 0:Another weird way to access the first element 42 | >.a. 43 | 44 | echo .$foo[3]. 45 | 0:An inner element 46 | >.c. 47 | 48 | echo .$foo[2,2]. 49 | 0:Another inner element 50 | >.b. 51 | 52 | echo .$foo[2,-4]. 53 | 0:A slice with a negative end 54 | >.b c d. 55 | 56 | echo .$foo[-4,5]. 57 | 0:A slice with a negative start 58 | >.d e. 59 | 60 | echo .$foo[-6,-2]. 61 | 0:A slice with a negative start and end 62 | >.b c d e f. 63 | 64 | echo .${${arr[2]}[1]}. 65 | echo .${${arr[-2]}[1]}. 66 | echo .${${arr[2,2]}[1]}. 67 | echo .${${arr[-2,-2]}[1]}. 68 | echo .${${arr[2,-2]}[1]}. 69 | echo .${${arr[-2,2]}[1]}. 70 | 0:Slices should return an array, elements a scalar 71 | >.b. 72 | >.b. 73 | >.bar. 74 | >.bar. 75 | >.bar. 76 | >.bar. 77 | 78 | setopt ksh_arrays 79 | echo .${foo[1,2]}. 80 | unsetopt ksh_arrays 81 | 0:Ksh array indexing 82 | >.b c. 83 | 84 | setopt ksh_arrays 85 | echo .${foo[0,1]}. 86 | unsetopt ksh_arrays 87 | 0:Ksh array indexing (ii) 88 | >.a b. 89 | 90 | setopt ksh_arrays 91 | echo .${foo[1,-1]}. 92 | unsetopt ksh_arrays 93 | 0:Ksh array indexing (iii) 94 | >.b c d e f g. 95 | 96 | cd array.tmp 97 | echo . ?([3,5]) . 98 | cd .. 99 | 0:Glob array indexing 100 | >. 3 4 5 . 101 | 102 | cd array.tmp 103 | echo . ?([2,-2]) . 104 | cd .. 105 | 0:Glob array indexing (ii) 106 | >. 2 3 4 5 6 7 8 . 107 | 108 | cd array.tmp 109 | echo . ?([-6,-4]) . 110 | cd .. 111 | 0:Glob array indexing (iii) 112 | >. 4 5 6 . 113 | -------------------------------------------------------------------------------- /Test/D06subscript.ztst: -------------------------------------------------------------------------------- 1 | # Test parameter subscripting. 2 | 3 | %prep 4 | 5 | s='Twinkle, twinkle, little *, [how] I [wonder] what? You are!' 6 | a=('1' ']' '?' '\2' '\]' '\?' '\\3' '\\]' '\\?' '\\\4' '\\\]' '\\\?') 7 | typeset -g -A A 8 | A=($a) 9 | 10 | %test 11 | 12 | x=',' 13 | print $s[(i)winkle] $s[(I)winkle] 14 | print ${s[(i)You are]} $#s 15 | print ${s[(r)$x,(R)$x]} 16 | 0:Scalar pattern subscripts without wildcards 17 | >2 11 18 | >53 60 19 | >, twinkle, little *, 20 | 21 | x='*' 22 | print $s[(i)*] $s[(i)\*] $s[(i)$x*] $s[(i)${(q)x}*] $s[(I)$x\*] 23 | print $s[(r)?,(R)\?] $s[(r)\?,(R)?] 24 | print $s[(r)\*,(R)*] 25 | print $s[(r)\],(R)\[] 26 | 0:Scalar pattern subscripts with wildcards 27 | >1 26 1 26 26 28 | >Twinkle, twinkle, little *, [how] I [wonder] what? ? You are! 29 | >*, [how] I [wonder] what? You are! 30 | >] I [ 31 | 32 | print $s[(i)x] : $s[(I)x] 33 | print $s[(r)x] : $s[(R)x] 34 | 0:Scalar pattern subscripts that do not match 35 | >61 : 0 36 | >: 37 | 38 | print -R $s[$s[(i)\[]] $s[(i)$s[(r)\*]] $s[(i)${(q)s[(r)\]]}] 39 | 0:Scalar subscripting using a pattern subscript to get the index 40 | >[ 1 33 41 | 42 | print -R $a[(r)?] $a[(R)?] 43 | print $a[(n:2:i)?] $a[(n:2:I)?] 44 | print $a[(i)\?] $a[(I)\?] 45 | print $a[(i)*] $a[(i)\*] 46 | 0:Array pattern subscripts 47 | >1 ? 48 | >2 2 49 | >3 3 50 | >1 13 51 | 52 | # It'd be nice to do some of the following with (r), but we run into 53 | # limitations of the ztst script parsing of backslashes in the output. 54 | print -R $a[(i)\\\\?] $a[(i)\\\\\?] 55 | print -R $a[(i)\\\\\\\\?] $a[(i)\\\\\\\\\?] 56 | print -R ${a[(i)\\\\\\\\?]} ${a[(i)\\\\\\\\\?]} 57 | print -R "$a[(i)\\\\\\\\?] $a[(i)\\\\\\\\\?]" 58 | print -R $a[(i)\]] $a[(i)\\\\\]] $a[(i)\\\\\\\\\]] $a[(i)\\\\\\\\\\\\\]] 59 | print -R $a[(i)${(q)a[5]}] $a[(i)${(q)a[8]}] $a[(i)${(q)a[11]}] 60 | print -R $a[(i)${a[3]}] $a[(i)${a[6]}] $a[(i)${a[9]}] $a[(i)${a[12]}] 61 | 0:Array pattern subscripts with multiple backslashes 62 | >4 6 63 | >7 9 64 | >7 9 65 | >7 9 66 | >2 5 8 11 67 | >5 8 11 68 | >1 3 4 6 69 | 70 | print -R $A[1] $A[?] $A[\\\\3] $A[\\\]] 71 | print -R $A[$a[11]] 72 | print -R $A[${(q)a[5]}] 73 | 0:Associative array lookup (direct subscripting) 74 | >] \2 \\] \? 75 | >\\\? 76 | >\\\? 77 | 78 | # The (o) is necessary here for predictable output ordering 79 | print -R $A[(I)\?] ${(o)A[(I)?]} 80 | print -R $A[(i)\\\\\\\\3] 81 | print -R $A[(I)\\\\\\\\\?] ${(o)A[(I)\\\\\\\\?]} 82 | 0:Associative array lookup (pattern subscripting) 83 | >? 1 ? 84 | >\\3 85 | >\\? \\3 \\? 86 | 87 | print -R $A[(R)\?] : ${(o)A[(R)?]} 88 | print -R $A[(R)\\\\\?] ${(o)A[(R)\\\\?]} ${(o)A[(R)\\\\\?]} 89 | print -R ${(o)A[(R)\\\\\\\\\]]} 90 | 0:Associative array lookup (reverse subscripting) 91 | >: ] 92 | >\? \2 \? \? 93 | >\\] 94 | 95 | eval 'A[*]=star' 96 | 1:Illegal associative array assignment 97 | ?(eval):1: A: attempt to set slice of associative array 98 | 99 | x='*' 100 | A[$x]=xstar 101 | A[${(q)x}]=qxstar 102 | print -R ${(k)A[(r)xstar]} $A[$x] 103 | print -R ${(k)A[(r)qxstar]} $A[${(q)x}] 104 | A[(e)*]=star 105 | A[\*]=backstar 106 | print -R ${(k)A[(r)star]} $A[(e)*] 107 | print -R ${(k)A[(r)backstar]} $A[\*] 108 | 0:Associative array assignment 109 | >* xstar 110 | >\* qxstar 111 | >* star 112 | >\* backstar 113 | 114 | o='[' 115 | c=']' 116 | A[\]]=cbrack 117 | A[\[]=obrack 118 | A[\\\[]=backobrack 119 | A[\\\]]=backcbrack 120 | print -R $A[$o] $A[$c] $A[\[] $A[\]] $A[\\\[] $A[\\\]] 121 | print -R $A[(i)\[] $A[(i)\]] $A[(i)\\\\\[] $A[(i)\\\\\]] 122 | 0:Associative array keys with open and close brackets 123 | >obrack cbrack obrack cbrack backobrack backcbrack 124 | >[ ] \[ \] 125 | 126 | print -R $A[$o] $A[$s[(r)\[]] 127 | print -R $A[(r)$c] $A[(r)$s[(r)\]]] 128 | print -R $A[$A[(i)\\\\\]]] 129 | 0:Associative array lookup using a pattern subscript to get the key 130 | >obrack obrack 131 | >] ] 132 | >backcbrack 133 | 134 | print -R ${A[${A[(r)\\\\\\\\\]]}]::=zounds} 135 | print -R ${A[${A[(r)\\\\\\\\\]]}]} 136 | print -R $A[\\\\\]] 137 | 0:Associative array substitution-assignment with reverse pattern subscript key 138 | >zounds 139 | >zounds 140 | >zounds 141 | 142 | print -R ${(o)A[(K)\]]} 143 | print -R ${(o)A[(K)\\\]]} 144 | 0:Associative array keys interpreted as patterns 145 | >\2 backcbrack cbrack star 146 | >\\\4 \\\? star zounds 147 | 148 | # It doesn't matter which element we get, since we never guarantee 149 | # ordering of an associative array. So just test the number of matches. 150 | array=(${(o)A[(k)\]]}) 151 | print ${#array} 152 | array=(${(o)A[(k)\\\]]}) 153 | print ${#array} 154 | 0:Associative array keys interpreted as patterns, single match 155 | >1 156 | >1 157 | 158 | typeset -g "A[one\"two\"three\"quotes]"=QQQ 159 | typeset -g 'A[one\"two\"three\"quotes]'=qqq 160 | print -R "$A[one\"two\"three\"quotes]" 161 | print -R $A[one\"two\"three\"quotes] 162 | A[one"two"three"four"quotes]=QqQq 163 | print -R $A[one"two"three"four"quotes] 164 | print -R $A[$A[(i)one\"two\"three\"quotes]] 165 | print -R "$A[$A[(i)one\"two\"three\"quotes]]" 166 | 0:Associative array keys with double quotes 167 | >QQQ 168 | >qqq 169 | >QqQq 170 | >qqq 171 | >QQQ 172 | 173 | print ${x::=$A[$A[(i)one\"two\"three\"quotes]]} 174 | print $x 175 | print ${x::="$A[$A[(i)one\"two\"three\"quotes]]"} 176 | print $x 177 | 0:More keys with double quotes, used in assignment-expansion 178 | >qqq 179 | >qqq 180 | >QQQ 181 | >QQQ 182 | 183 | qqq=lower 184 | QQQ=upper 185 | print ${(P)A[one\"two\"three\"quotes]} 186 | print "${(P)A[$A[(i)one\"two\"three\"quotes]]}" 187 | 0:Keys with double quotes and the (P) expansion flag 188 | >lower 189 | >upper 190 | 191 | typeset -ga empty 192 | echo X${${empty##*}[-1]}X 193 | 0:Negative index applied to substition result from empty array 194 | >XX 195 | 196 | print $empty[(i)] $empty[(I)] 197 | 0:(i) returns 1 for empty array, (I) returns 0. 198 | >1 0 199 | 200 | array=(one two three four) 201 | print X$array[0]X 202 | 0:Element zero is empty if KSH_ZERO_SUBSCRIPT is off. 203 | >XX 204 | 205 | array[0]=fumble 206 | 1:Can't set element zero if KSH_ZERO_SUBSCRIPT is off. 207 | ?(eval):1: array: assignment to invalid subscript range 208 | 209 | print X$array[(R)notfound]X 210 | 0:(R) returns empty if not found if KSH_ZERO_SUBSCRIPT is off. 211 | >XX 212 | 213 | setopt KSH_ZERO_SUBSCRIPT 214 | print X$array[0]X 215 | 0:Element zero is element one if KSH_ZERO_SUBSCRIPT is on. 216 | >XoneX 217 | 218 | array[0]=fimble 219 | print $array 220 | 0:Can set element zero if KSH_ZERO_SUBSCRIPT is on. 221 | >fimble two three four 222 | 223 | print X$array[(R)notfound]X 224 | 0:(R) yuckily returns the first element on failure withe KSH_ZERO_SUBSCRIPT 225 | >XfimbleX 226 | 227 | unsetopt KSH_ZERO_SUBSCRIPT 228 | array[(R)notfound,(r)notfound]=(help help here come the seventies retreads) 229 | print $array 230 | 0:[(R)notfound,(r)notfound] replaces the whole array 231 | >help help here come the seventies retreads 232 | 233 | string="Why, if it isn't Officer Dibble" 234 | print "[${string[0]}][${string[1]}][${string[0,3]}]" 235 | 0:String subscripts with KSH_ZERO_SUBSCRIPT unset 236 | >[][W][Why] 237 | 238 | setopt KSH_ZERO_SUBSCRIPT 239 | print "[${string[0]}][${string[1]}][${string[0,3]}]" 240 | 0:String subscripts with KSH_ZERO_SUBSCRIPT set 241 | >[W][W][Why] 242 | 243 | unsetopt KSH_ZERO_SUBSCRIPT 244 | string[0,3]="Goodness" 245 | print $string 246 | 0:Assignment to chunk of string ignores element 0 247 | >Goodness, if it isn't Officer Dibble 248 | 249 | string[0]=! 250 | 1:Can't set only element zero of string 251 | ?(eval):1: string: assignment to invalid subscript range 252 | 253 | typeset -A assoc=(leader topcat officer dibble sidekick choochoo) 254 | alias myind='echo leader' myletter='echo 1' myletter2='echo 4' 255 | print ${assoc[$(myind)]} 256 | print $assoc[$(myind)] 257 | print ${assoc[$(myind)][$(myletter)]}${assoc[$(myind)][$(myletter2)]} 258 | assoc[$(myind)]='of the gang' 259 | print ${assoc[$(myind)]} 260 | print $assoc[$(myind)] 261 | print $assoc[leader] 262 | 0: Parsing subscript with non-trivial tokenisation 263 | >topcat 264 | >topcat 265 | >tc 266 | >of the gang 267 | >of the gang 268 | >of the gang 269 | -------------------------------------------------------------------------------- /Test/D08cmdsubst.ztst: -------------------------------------------------------------------------------- 1 | # Tests for command substitution. 2 | 3 | %prep 4 | mkdir cmdsubst.tmp 5 | touch cmdsubst.tmp/file{1,2}.txt 6 | 7 | %test 8 | foo="two words" 9 | print -l `echo $foo bar` 10 | 0:Basic `...` substitution 11 | >two 12 | >words 13 | >bar 14 | 15 | foo="two words" 16 | print -l $(echo $foo bar) 17 | 0:Basic $(...) substitution 18 | >two 19 | >words 20 | >bar 21 | 22 | foo='intricate buffoonery' 23 | print -l "`echo $foo and licentiousness`" 24 | 0:Quoted `...` substitution 25 | >intricate buffoonery and licentiousness 26 | 27 | foo="more words" 28 | print -l "$(echo $foo here)" 29 | 0:Quoted $(...) substitution 30 | >more words here 31 | 32 | # we used never to get this one right, but I think it is now... 33 | print -r "`print -r \\\\\\\\`" 34 | 0:Stripping of backslasshes in quoted `...` 35 | >\\ 36 | 37 | print -r "$(print -r \\\\\\\\)" 38 | 0:Stripping of backslashes in quoted $(...) 39 | >\\\\ 40 | 41 | fnify() { print \"$*\"; } 42 | print `fnify \`fnify understatement\`` 43 | 0:Nested `...` 44 | >""understatement"" 45 | 46 | print $(fnify $(fnify overboard)) 47 | 0:Nested $(...) 48 | >""overboard"" 49 | 50 | fructify() { print \'$*\'; } 51 | print "`fructify \`fructify indolence\``" 52 | 0:Nested quoted `...` 53 | >''indolence'' 54 | 55 | print "$(fructify $(fructify obtuseness))" 56 | 0:Nested quoted $(...) 57 | >''obtuseness'' 58 | 59 | gesticulate() { print \!$*\!; } 60 | print $((gesticulate wildly); gesticulate calmly) 61 | 0:$(( ... ) ... ) is not arithmetic 62 | >!wildly! !calmly! 63 | 64 | commencify() { print +$*+; } 65 | print "$((commencify output); commencify input)" 66 | 0:quoted $(( ... ) .. ) is not arithmetic 67 | >+output+ 68 | >+input+ 69 | 70 | ( 71 | cd cmdsubst.tmp 72 | print first: ${$(print \*)} 73 | print second: ${~$(print \*)} 74 | print third: ${$(print *)} 75 | print fourth: "${~$(print \*)}" 76 | print fifth: ${~"$(print \*)"} 77 | ) 78 | 0:mixing $(...) with parameter substitution and globbing 79 | >first: * 80 | >second: file1.txt file2.txt 81 | >third: file1.txt file2.txt 82 | >fourth: * 83 | >fifth: file1.txt file2.txt 84 | 85 | $(exit 0) $(exit 3) || print $? 86 | 0:empty command uses exit value of last substitution 87 | >3 88 | 89 | X=$(exit 2) $(exit 0) || print $? 90 | 0:variable assignments processed after other substitutions 91 | >2 92 | 93 | false 94 | `` 95 | 0:Empty command substitution resets status 96 | 97 | false 98 | echo `echo $?` 99 | 0:Non-empty command substitution inherits status 100 | >1 101 | 102 | echo $(( ##\" )) 103 | echo $(echo \") 104 | echo $((echo \"); echo OK) 105 | 0:Handling of backslash double quote in parenthesised substitutions 106 | >34 107 | >" 108 | >" OK 109 | 110 | echo $(case foo in 111 | foo) 112 | echo This test worked. 113 | ;; 114 | bar) 115 | echo This test failed in a rather bizarre way. 116 | ;; 117 | *) 118 | echo This test failed. 119 | ;; 120 | esac) 121 | 0:Parsing of command substitution with unmatched parentheses: case, basic 122 | >This test worked. 123 | 124 | echo "$(case bar in 125 | foo) 126 | echo This test spoobed. 127 | ;; 128 | bar) 129 | echo This test plurbled. 130 | ;; 131 | *) 132 | echo This test bzonked. 133 | ;; 134 | esac)" 135 | 0:Parsing of command substitution with unmatched parentheses: case with quotes 136 | >This test plurbled. 137 | 138 | echo before $( 139 | echo start; echo unpretentious | 140 | while read line; do 141 | case $line in 142 | u*) 143 | print Word began with u 144 | print and ended with a crunch 145 | ;; 146 | esac 147 | done | sed -e 's/Word/Universe/'; echo end 148 | ) after 149 | 0:Parsing of command substitution with ummatched parentheses: with frills 150 | >before start Universe began with u and ended with a crunch end after 151 | 152 | alias foo='echo $(' 153 | eval 'foo echo this just works, OK\?)' 154 | 0:backtracking within command string parsing with alias still pending 155 | >this just works, OK? 156 | 157 | ( 158 | set errexit 159 | show_nargs() { print $#; } 160 | print a $() b 161 | print c "$()" d 162 | ) 163 | 0:Empty $() is a valid empty substitution. 164 | >a b 165 | >c d 166 | 167 | empty=$() && print "'$empty'" 168 | 0:Empty $() is a valid assignment 169 | >'' 170 | -------------------------------------------------------------------------------- /Test/D09brace.ztst: -------------------------------------------------------------------------------- 1 | # Tests for brace expansion 2 | 3 | %prep 4 | 5 | foo=(a b c) 6 | arr=(foo bar baz) 7 | 8 | %test 9 | 10 | print X{1,2,{3..6},7,8}Y 11 | 0:Basic brace expansion 12 | >X1Y X2Y X3Y X4Y X5Y X6Y X7Y X8Y 13 | 14 | print ${foo}{one,two,three}$arr 15 | 0:Brace expansion with arrays, no RC_EXPAND_PARAM 16 | >a b conefoo ctwofoo cthreefoo bar baz 17 | 18 | print ${^foo}{one,two,three}$arr 19 | 0:Brace expansion with arrays, with RC_EXPAND_PARAM (1) 20 | >aonefoo atwofoo athreefoo bonefoo btwofoo bthreefoo conefoo ctwofoo cthreefoo bar baz 21 | 22 | print ${foo}{one,two,three}$^arr 23 | 0:Brace expansion with arrays, with RC_EXPAND_PARAM (2) 24 | >a b conefoo ctwofoo cthreefoo conebar ctwobar cthreebar conebaz ctwobaz cthreebaz 25 | 26 | print ${^foo}{one,two,three}$^arr 27 | 0:Brace expansion with arrays, with RC_EXPAND_PARAM (3) 28 | >aonefoo atwofoo athreefoo aonebar atwobar athreebar aonebaz atwobaz athreebaz bonefoo btwofoo bthreefoo bonebar btwobar bthreebar bonebaz btwobaz bthreebaz conefoo ctwofoo cthreefoo conebar ctwobar cthreebar conebaz ctwobaz cthreebaz 29 | 30 | print X{01..4}Y 31 | 0:Numeric range expansion, padding (1) 32 | >X01Y X02Y X03Y X04Y 33 | 34 | print X{1..04}Y 35 | 0:Numeric range expansion, padding (2) 36 | >X01Y X02Y X03Y X04Y 37 | 38 | print X{7..12}Y 39 | 0:Numeric range expansion, padding (or not) (3) 40 | >X7Y X8Y X9Y X10Y X11Y X12Y 41 | 42 | print X{07..12}Y 43 | 0:Numeric range expansion, padding (4) 44 | >X07Y X08Y X09Y X10Y X11Y X12Y 45 | 46 | print X{7..012}Y 47 | 0:Numeric range expansion, padding (5) 48 | >X007Y X008Y X009Y X010Y X011Y X012Y 49 | 50 | print X{4..1}Y 51 | 0:Numeric range expansion, decreasing 52 | >X4Y X3Y X2Y X1Y 53 | 54 | print X{1..4}{1..4}Y 55 | 0:Numeric range expansion, combined braces 56 | >X11Y X12Y X13Y X14Y X21Y X22Y X23Y X24Y X31Y X32Y X33Y X34Y X41Y X42Y X43Y X44Y 57 | 58 | print X{-4..4}Y 59 | 0:Numeric range expansion, negative numbers (1) 60 | >X-4Y X-3Y X-2Y X-1Y X0Y X1Y X2Y X3Y X4Y 61 | 62 | print X{4..-4}Y 63 | 0:Numeric range expansion, negative numbers (2) 64 | >X4Y X3Y X2Y X1Y X0Y X-1Y X-2Y X-3Y X-4Y 65 | 66 | print X{004..-4..2}Y 67 | 0:Numeric range expansion, stepping and padding (1) 68 | >X004Y X002Y X000Y X-02Y X-04Y 69 | 70 | print X{4..-4..02}Y 71 | 0:Numeric range expansion, stepping and padding (1) 72 | >X04Y X02Y X00Y X-2Y X-4Y 73 | 74 | print X{1..32..3}Y 75 | 0:Numeric range expansion, step alignment (1) 76 | >X1Y X4Y X7Y X10Y X13Y X16Y X19Y X22Y X25Y X28Y X31Y 77 | 78 | print X{1..32..-3}Y 79 | 0:Numeric range expansion, step alignment (2) 80 | >X31Y X28Y X25Y X22Y X19Y X16Y X13Y X10Y X7Y X4Y X1Y 81 | 82 | print X{32..1..3}Y 83 | 0:Numeric range expansion, step alignment (3) 84 | >X32Y X29Y X26Y X23Y X20Y X17Y X14Y X11Y X8Y X5Y X2Y 85 | 86 | print X{32..1..-3}Y 87 | 0:Numeric range expansion, step alignment (4) 88 | >X2Y X5Y X8Y X11Y X14Y X17Y X20Y X23Y X26Y X29Y X32Y 89 | 90 | setopt brace_ccl 91 | print X{za-q521}Y 92 | unsetopt brace_ccl 93 | 0:BRACE_CCL on 94 | >X1Y X2Y X5Y XaY XbY XcY XdY XeY XfY XgY XhY XiY XjY XkY XlY XmY XnY XoY XpY XqY XzY 95 | 96 | print X{za-q521}Y 97 | 0:BRACE_CCL off 98 | >X{za-q521}Y 99 | 100 | print -r hey{a..j}there 101 | 0:{char..char} ranges, simple case 102 | >heyathere heybthere heycthere heydthere heyethere heyfthere heygthere heyhthere heyithere heyjthere 103 | 104 | print -r gosh{1,{Z..a},2}cripes 105 | 0:{char..char} ranges, ASCII ordering 106 | >gosh1cripes goshZcripes gosh[cripes gosh\cripes gosh]cripes gosh^cripes gosh_cripes gosh`cripes goshacripes gosh2cripes 107 | 108 | print -r crumbs{y..p}ooh 109 | 0:{char..char} ranges, reverse 110 | >crumbsyooh crumbsxooh crumbswooh crumbsvooh crumbsuooh crumbstooh crumbssooh crumbsrooh crumbsqooh crumbspooh 111 | 112 | print -r left{[..]}right 113 | 0:{char..char} ranges with tokenized characters 114 | >left[right left\right left]right 115 | -------------------------------------------------------------------------------- /Test/E02xtrace.ztst: -------------------------------------------------------------------------------- 1 | # Test that xtrace output is correctly generated 2 | 3 | %prep 4 | mkdir xtrace.tmp && cd xtrace.tmp 5 | 6 | function xtf { 7 | local regression_test_dummy_variable 8 | print "$*" 9 | } 10 | function xtfx { 11 | local regression_test_dummy_variable 12 | print "Tracing: (){ builtin 2>file }" 2>>xtrace.err 13 | { print "Tracing: (){ { builtin } 2>file }" } 2>>xtrace.err 14 | } 15 | echo 'print "$*"' > xt.in 16 | 17 | %test 18 | 19 | PS4='+%N:%i> ' 20 | set -x 21 | print 'Tracing: builtin' 22 | print 'Tracing: builtin 2>file' 2>xtrace.err 23 | cat <<<'Tracing: external' 24 | cat <<<'Tracing: external 2>file' 2>>xtrace.err 25 | ( print 'Tracing: ( builtin )' ) 26 | ( print 'Tracing: ( builtin ) 2>file' ) 2>>xtrace.err 27 | ( cat <<<'Tracing: ( external )' ) 28 | ( cat <<<'Tracing: ( external ) 2>file' ) 2>>xtrace.err 29 | { print 'Tracing: { builtin }' } 30 | { print 'Tracing: { builtin } 2>file' } 2>>xtrace.err 31 | { cat <<<'Tracing: { external }' } 32 | { cat <<<'Tracing: { external } 2>file' } 2>>xtrace.err 33 | repeat 1 do print 'Tracing: do builtin done'; done 34 | repeat 1 do print 'Tracing: do builtin done 2>file'; done 2>>xtrace.err 35 | repeat 1 do cat <<<'Tracing: do external done'; done 36 | repeat 1 do cat <<<'Tracing: do external done 2>file'; done 2>>xtrace.err 37 | xtf 'Tracing: function' 38 | xtf 'Tracing: function 2>file' 2>>xtrace.err 39 | xtfx 40 | . ./xt.in 'Tracing: source' 41 | . ./xt.in 'Tracing: source 2>file' 2>>xtrace.err 42 | set +x 43 | cat xtrace.err 44 | 0:xtrace with and without redirection 45 | >Tracing: builtin 46 | >Tracing: builtin 2>file 47 | >Tracing: external 48 | >Tracing: external 2>file 49 | >Tracing: ( builtin ) 50 | >Tracing: ( builtin ) 2>file 51 | >Tracing: ( external ) 52 | >Tracing: ( external ) 2>file 53 | >Tracing: { builtin } 54 | >Tracing: { builtin } 2>file 55 | >Tracing: { external } 56 | >Tracing: { external } 2>file 57 | >Tracing: do builtin done 58 | >Tracing: do builtin done 2>file 59 | >Tracing: do external done 60 | >Tracing: do external done 2>file 61 | >Tracing: function 62 | >Tracing: function 2>file 63 | >Tracing: (){ builtin 2>file } 64 | >Tracing: (){ { builtin } 2>file } 65 | >Tracing: source 66 | >Tracing: source 2>file 67 | >+(eval):8> print 'Tracing: ( builtin ) 2>file' 68 | >+(eval):10> cat 69 | >+(eval):12> print 'Tracing: { builtin } 2>file' 70 | >+(eval):14> cat 71 | >+(eval):16> print 'Tracing: do builtin done 2>file' 72 | >+(eval):18> cat 73 | >+xtf:1> local regression_test_dummy_variable 74 | >+xtf:2> print 'Tracing: function 2>file' 75 | >+xtfx:3> print 'Tracing: (){ { builtin } 2>file }' 76 | ?+(eval):3> print 'Tracing: builtin' 77 | ?+(eval):4> print 'Tracing: builtin 2>file' 78 | ?+(eval):5> cat 79 | ?+(eval):6> cat 80 | ?+(eval):7> print 'Tracing: ( builtin )' 81 | ?+(eval):9> cat 82 | ?+(eval):11> print 'Tracing: { builtin }' 83 | ?+(eval):13> cat 84 | ?+(eval):15> print 'Tracing: do builtin done' 85 | ?+(eval):17> cat 86 | ?+(eval):19> xtf 'Tracing: function' 87 | ?+xtf:1> local regression_test_dummy_variable 88 | ?+xtf:2> print 'Tracing: function' 89 | ?+(eval):20> xtf 'Tracing: function 2>file' 90 | ?+(eval):21> xtfx 91 | ?+xtfx:1> local regression_test_dummy_variable 92 | ?+xtfx:2> print 'Tracing: (){ builtin 2>file }' 93 | ?+(eval):22> . ./xt.in 'Tracing: source' 94 | ?+./xt.in:1> print 'Tracing: source' 95 | ?+(eval):23> . ./xt.in 'Tracing: source 2>file' 96 | ?+./xt.in:1> print 'Tracing: source 2>file' 97 | ?+(eval):24> set +x 98 | 99 | typeset -ft xtf 100 | xtf 'Tracing: function' 101 | 0:tracing function 102 | >Tracing: function 103 | ?+xtf:1> local regression_test_dummy_variable 104 | ?+xtf:2> print 'Tracing: function' 105 | 106 | echo 'PS4="+%x:%I> " 107 | fn() { 108 | print This is fn. 109 | } 110 | : 111 | fn 112 | ' >fnfile 113 | $ZTST_testdir/../Src/zsh -fx ./fnfile 2>errfile 114 | grep '\./fnfile' errfile 1>&2 115 | 0:Trace output with sourcefile and line number. 116 | >This is fn. 117 | ?+./fnfile:1> PS4='+%x:%I> ' 118 | ?+./fnfile:5> : 119 | ?+./fnfile:6> fn 120 | ?+./fnfile:3> print This is fn. 121 | 122 | set -x 123 | [[ 'f o' == 'f x'* || 'b r' != 'z o' && 'squashy sound' < 'squishy sound' ]] 124 | [[ 'f o' = 'f x'* || 'b r' != 'z o' && 'squashy sound' < 'squishy sound' ]] 125 | [[ -e nonexistentfile || ( -z '' && -t 3 ) ]] 126 | set +x 127 | 0:Trace for conditions 128 | ?+(eval):2> [[ 'f o' == f\ x* || 'b r' != z\ o && 'squashy sound' < 'squishy sound' ]] 129 | ?+(eval):3> [[ 'f o' = f\ x* || 'b r' != z\ o && 'squashy sound' < 'squishy sound' ]] 130 | ?+(eval):4> [[ -e nonexistentfile || -z '' && -t 3 ]] 131 | ?+(eval):5> set +x 132 | 133 | # Part 1: Recurses into nested anonymous functions 134 | fn() { 135 | () { () { true } } 136 | } 137 | functions -T fn 138 | fn 139 | # Part 2: Doesn't recurse into named functions 140 | gn() { true } 141 | fn() { gn } 142 | functions -T fn 143 | fn 144 | 0:tracing recurses into anonymous functions 145 | ?+fn:1> '(anon)' 146 | ?+(anon):0> '(anon)' 147 | ?+(anon):0> true 148 | ?+fn:0> gn 149 | -------------------------------------------------------------------------------- /Test/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Test subdirectory 3 | # 4 | # Copyright (c) 1999 Peter Stephensons 5 | # All rights reserved. 6 | # 7 | # Permission is hereby granted, without written agreement and without 8 | # license or royalty fees, to use, copy, modify, and distribute this 9 | # software and to distribute modified versions of this software for any 10 | # purpose, provided that the above copyright notice and the following 11 | # two paragraphs appear in all copies of this software. 12 | # 13 | # In no event shall Peter Stephenson or the Zsh Development Group be liable 14 | # to any party for direct, indirect, special, incidental, or consequential 15 | # damages arising out of the use of this software and its documentation, 16 | # even if Peter Stephenson and the Zsh Development Group have been advised of 17 | # the possibility of such damage. 18 | # 19 | # Peter Stephenson and the Zsh Development Group specifically disclaim any 20 | # warranties, including, but not limited to, the implied warranties of 21 | # merchantability and fitness for a particular purpose. The software 22 | # provided hereunder is on an "as is" basis, and Peter Stephenson and the 23 | # Zsh Development Group have no obligation to provide maintenance, 24 | # support, updates, enhancements, or modifications. 25 | # 26 | 27 | subdir = Test 28 | dir_top = .. 29 | SUBDIRS = 30 | 31 | @VERSION_MK@ 32 | 33 | # source/build directories 34 | VPATH = @srcdir@ 35 | sdir = @srcdir@ 36 | sdir_top = @top_srcdir@ 37 | INSTALL = @INSTALL@ 38 | 39 | @DEFS_MK@ 40 | 41 | # ========== DEPENDENCIES FOR TESTING ========== 42 | 43 | check test: 44 | if test -n "$(DLLD)"; then \ 45 | cd $(dir_top) && DESTDIR= \ 46 | $(MAKE) MODDIR=`pwd`/$(subdir)/Modules install.modules > /dev/null; \ 47 | fi 48 | if ZTST_testlist="`for f in $(sdir)/$(TESTNUM)*.ztst; \ 49 | do echo $$f; done`" \ 50 | ZTST_srcdir="$(sdir)" \ 51 | ZTST_exe=$(dir_top)/Src/zsh@EXEEXT@ \ 52 | $(dir_top)/Src/zsh@EXEEXT@ +Z -f $(sdir)/runtests.zsh; then \ 53 | stat=0; \ 54 | else \ 55 | stat=1; \ 56 | fi; \ 57 | sleep 1; \ 58 | rm -rf Modules .zcompdump; \ 59 | exit $$stat 60 | 61 | # ========== DEPENDENCIES FOR CLEANUP ========== 62 | 63 | @CLEAN_MK@ 64 | 65 | mostlyclean-here: 66 | rm -rf Modules .zcompdump *.tmp 67 | 68 | distclean-here: 69 | rm -f Makefile 70 | 71 | realclean-here: 72 | 73 | # ========== DEPENDENCIES FOR MAINTENANCE ========== 74 | 75 | @CONFIG_MK@ 76 | -------------------------------------------------------------------------------- /Test/README: -------------------------------------------------------------------------------- 1 | There are now different sections, expressed by the first letter in the 2 | scripts names: 3 | 4 | A: basic command parsing and execution 5 | B: builtins 6 | C: shell commands with special syntax 7 | D: substititution 8 | E: options 9 | V: modules 10 | W: builtin interactive commands and constructs 11 | X: line editing 12 | Y: completion 13 | Z: separate systems and user contributions 14 | 15 | You will need to run these by using `make test' in the Test subdirectory of 16 | the build area for your system (which may or may not be the same as the 17 | Test subdirectory of the source tree), or the directory above. You can get 18 | more information about the tests being performed with 19 | ZTST_verbose=1 make check 20 | (`test' is equivalent to `check') or change 1 to 2 for even more detail. 21 | 22 | Individual or groups of tests can be performed with 23 | make TESTNUM=C02 check 24 | or 25 | make TESTNUM=C check 26 | to perform just the test beginning C02, or all tests beginning C, 27 | respectively. 28 | 29 | Instructions on how to write tests are given in B01cd.ztst, which acts as a 30 | model. 31 | -------------------------------------------------------------------------------- /Test/V03mathfunc.ztst: -------------------------------------------------------------------------------- 1 | # Tests for the module zsh/mathfunc 2 | 3 | %prep 4 | if ! zmodload zsh/mathfunc 2>/dev/null; then 5 | ZTST_unimplemented="The module zsh/mathfunc is not available." 6 | fi 7 | 8 | %test 9 | # -g makes pi available in later tests 10 | float -gF 5 pi 11 | (( pi = 4 * atan(1.0) )) 12 | print $pi 13 | 0:Basic operation with atan 14 | >3.14159 15 | 16 | float -F 5 result 17 | (( result = atan(3,2) )) 18 | print $result 19 | 0:atan with two arguments 20 | >0.98279 21 | 22 | print $(( atan(1,2,3) )) 23 | 1:atan can't take three arguments 24 | ?(eval):1: wrong number of arguments: atan(1,2,3) 25 | 26 | float r1=$(( rand48() )) 27 | float r2=$(( rand48() )) 28 | float r3=$(( rand48() )) 29 | # Yes, this is a floating point equality test like they tell 30 | # you not to do. As the pseudrandom sequence is deterministic, 31 | # this is the right thing to do in this case. 32 | if (( r1 == r2 )); then 33 | print "Seed not updated correctly the first time" 34 | else 35 | print "First two random numbers differ, OK" 36 | fi 37 | if (( r2 == r3 )); then 38 | print "Seed not updated correctly the second time" 39 | else 40 | print "Second two random numbers differ, OK" 41 | fi 42 | 0:rand48 with default initialisation 43 | F:This test fails if your math library doesn't have erand48(). 44 | >First two random numbers differ, OK 45 | >Second two random numbers differ, OK 46 | 47 | seed=f45677a6cbe4 48 | float r1=$(( rand48(seed) )) 49 | float r2=$(( rand48(seed) )) 50 | seed2=$seed 51 | float r3=$(( rand48(seed) )) 52 | float r4=$(( rand48(seed2) )) 53 | # Yes, this is a floating point equality test like they tell 54 | # you not to do. As the pseudrandom sequence is deterministic, 55 | # this is the right thing to do in this case. 56 | if (( r1 == r2 )); then 57 | print "Seed not updated correctly the first time" 58 | else 59 | print "First two random numbers differ, OK" 60 | fi 61 | if (( r2 == r3 )); then 62 | print "Seed not updated correctly the second time" 63 | else 64 | print "Second two random numbers differ, OK" 65 | fi 66 | if (( r3 == r4 )); then 67 | print "Identical seeds generate identical numbers, OK" 68 | else 69 | print "Indeterminate result from identical seeds" 70 | fi 71 | 0:rand48 with pre-generated seed 72 | F:This test fails if your math library doesn't have erand48(). 73 | >First two random numbers differ, OK 74 | >Second two random numbers differ, OK 75 | >Identical seeds generate identical numbers, OK 76 | 77 | float -F 5 pitest 78 | (( pitest = 4.0 * atan(1) )) 79 | # This is a string test of the output to 5 digits. 80 | if [[ $pi = $pitest ]]; then 81 | print "OK, atan on an integer seemed to work" 82 | else 83 | print "BAD: got $pitest instead of $pi" 84 | fi 85 | 0:Conversion of arguments from integer 86 | >OK, atan on an integer seemed to work 87 | 88 | float -F 5 result 89 | typeset str 90 | for str in 0 0.0 1 1.5 -1 -1.5; do 91 | (( result = abs($str) )) 92 | print $result 93 | done 94 | 0:Use of abs on various numbers 95 | >0.00000 96 | >0.00000 97 | >1.00000 98 | >1.50000 99 | >1.00000 100 | >1.50000 101 | 102 | print $(( sqrt(-1) )) 103 | 1:Non-negative argument checking for square roots. 104 | ?(eval):1: math: argument to sqrt out of range 105 | 106 | # Simple test that the pseudorandom number generators are producing 107 | # something that could conceivably be pseudorandom numbers in a 108 | # linear range. Not a detailed quantitative verification. 109 | integer N=10000 isource ok=1 110 | float -F f sum sumsq max max2 av sd 111 | typeset -a randoms 112 | randoms=('f = RANDOM' 'f = rand48()') 113 | for isource in 1 2; do 114 | (( sum = sumsq = max = 0 )) 115 | repeat $N; do 116 | let $randoms[$isource] 117 | (( f > max )) && (( max = f )) 118 | (( sum += f, sumsq += f * f )) 119 | done 120 | (( av = sum / N )) 121 | (( sd = sqrt((sumsq - N * av * av) / (N-1)) )) 122 | (( max2 = 0.5 * max )) 123 | if (( av > max2 * 1.1 )) || (( av < max2 * 0.9 )); then 124 | print "WARNING: average of random numbers is suspicious. 125 | Was testing: $randoms[$isource]" 126 | (( ok = 0 )) 127 | fi 128 | if (( sd < max / 4 )); then 129 | print "WARNING: distribution of random numbers is suspicious. 130 | Was testing: $randoms[$isource]" 131 | (( ok = 0 )) 132 | fi 133 | done 134 | (( ok )) 135 | 0:Test random number generator distributions are not grossly broken 136 | 137 | float -F 5 g l 138 | (( g = gamma(2), l = lgamma(2) )) 139 | print $g, $l 140 | 0:Test Gamma function gamma and lgamma 141 | >1.00000, 0.00000 142 | -------------------------------------------------------------------------------- /Test/V04features.ztst: -------------------------------------------------------------------------------- 1 | %prep 2 | 3 | # Do some tests on handling of features. 4 | # This also does some slightly more sophisticated loading and 5 | # unloading tests than we did in V01zmodload.ztst. 6 | # 7 | # We use zsh/datetime because it has a list of features that is short 8 | # but contains two types. 9 | 10 | # Subshell for prep test so we can load individual features later 11 | if ! (zmodload zsh/datetime 2>/dev/null); then 12 | ZTST_unimplemented="can't load the zsh/datetime module for testing" 13 | fi 14 | 15 | %test 16 | zmodload -F zsh/datetime 17 | zmodload -lF zsh/datetime 18 | 0:Loading modules with no features 19 | >-b:strftime 20 | >-p:EPOCHSECONDS 21 | >-p:EPOCHREALTIME 22 | >-p:epochtime 23 | 24 | zmodload -F zsh/datetime b:strftime 25 | zmodload -lF zsh/datetime 26 | 0:Enabling features 27 | >+b:strftime 28 | >-p:EPOCHSECONDS 29 | >-p:EPOCHREALTIME 30 | >-p:epochtime 31 | 32 | zmodload -F zsh/datetime +p:EPOCHSECONDS -b:strftime 33 | zmodload -lF zsh/datetime 34 | 0:Disabling features 35 | >-b:strftime 36 | >+p:EPOCHSECONDS 37 | >-p:EPOCHREALTIME 38 | >-p:epochtime 39 | 40 | zmodload -Fe zsh/datetime p:EPOCHSECONDS b:strftime 41 | 0:Testing existing features 42 | 43 | zmodload -Fe zsh/datetime +p:EPOCHSECONDS 44 | 0:Testing features are in given state (on feature is on) 45 | 46 | zmodload -Fe zsh/datetime -p:EPOCHSECONDS 47 | 1:Testing features are in given state (on feature is not off 48 | 49 | zmodload -Fe zsh/datetime +p:strftime 50 | 1:Testing features are in given state (off feature is not on) 51 | 52 | zmodload -Fe zsh/datetime -b:strftime 53 | 0:Testing features are in given state (off feature is off 54 | 55 | zmodload -Fe zsh/datetime p:EPOCHSECONDS b:strftime b:mktimebetter 56 | 1:Testing non-existent features 57 | 58 | zmodload -FlP dtf zsh/datetime 59 | for feature in b:strftime p:EPOCHSECONDS; do 60 | if [[ ${${dtf[(R)?$feature]}[1]} = + ]]; then 61 | print $feature is enabled 62 | else 63 | print $feature is disabled 64 | fi 65 | done 66 | 0:Testing features via array parameter 67 | >b:strftime is disabled 68 | >p:EPOCHSECONDS is enabled 69 | 70 | fn() { 71 | local EPOCHSECONDS=scruts 72 | print $EPOCHSECONDS 73 | print ${(t)EPOCHSECONDS} 74 | } 75 | fn 76 | if [[ $EPOCHSECONDS = <-> ]]; then 77 | print EPOCHSECONDS is a number 78 | else 79 | print EPOCHSECONDS is some random piece of junk 80 | fi 81 | print ${(t)EPOCHSECONDS} 82 | 0:Module special parameter is hidden by a local parameter 83 | >scruts 84 | >scalar-local 85 | >EPOCHSECONDS is a number 86 | >integer-readonly-hide-hideval-special 87 | 88 | typeset +h EPOCHSECONDS 89 | fn() { 90 | local EPOCHSECONDS=scruts 91 | print Didn\'t get here >&2 92 | } 93 | fn 94 | 1:Unhidden readonly special can't be assigned to when made local 95 | ?fn:1: read-only variable: EPOCHSECONDS 96 | 97 | zmodload -u zsh/datetime 98 | 0:Module unloaded 99 | 100 | zmodload -e zsh/datetime 101 | 1:Module doesn't exist when unloaded 102 | 103 | zmodload -Fe zsh/datetime p:EPOCHSECONDS 104 | 1:Module doesn't have features when unloaded 105 | 106 | fn() { 107 | local EPOCHSECONDS=scrimf 108 | zmodload zsh/datetime 109 | } 110 | fn 111 | 2:Failed to add parameter if local parameter present 112 | ?fn:2: Can't add module parameter `EPOCHSECONDS': local parameter exists 113 | ?fn:zsh/datetime:2: error when adding parameter `EPOCHSECONDS' 114 | 115 | zmodload -lF zsh/datetime 116 | 0:Feature state with loading after error enabling 117 | >+b:strftime 118 | >-p:EPOCHSECONDS 119 | >+p:EPOCHREALTIME 120 | >+p:epochtime 121 | 122 | zmodload -F zsh/datetime p:EPOCHSECONDS 123 | zmodload -Fe zsh/datetime +p:EPOCHSECONDS 124 | 0:Successfully added feature parameter that previously failed 125 | 126 | fn() { 127 | local EPOCHSECONDS=scrooble 128 | zmodload -u zsh/datetime 129 | print $EPOCHSECONDS 130 | } 131 | fn 132 | print ${+EPOCHSECONDS} 133 | 0:Successfully unloaded a module despite a parameter being hidden 134 | >scrooble 135 | >0 136 | 137 | EPOCHSECONDS=(any old parameter) 138 | print -l $EPOCHSECONDS 139 | 0:Using parameter as normal after unloading is OK 140 | >any 141 | >old 142 | >parameter 143 | 144 | print strftime is ${builtins[strftime]:-undefined} 145 | zmodload -F zsh/datetime b:strftime 146 | print strftime is ${builtins[strftime]:-undefined} 147 | zmodload -F zsh/datetime -b:strftime 148 | print strftime is ${builtins[strftime]:-undefined} 149 | 0:Enabling and disabling of builtins as features 150 | >strftime is undefined 151 | >strftime is defined 152 | >strftime is undefined 153 | 154 | zmodload -u zsh/datetime 155 | zmodload zsh/datetime 156 | 2:Loading won't override global parameter 157 | ?(eval):2: Can't add module parameter `EPOCHSECONDS': parameter already exists 158 | ?(eval):zsh/datetime:2: error when adding parameter `EPOCHSECONDS' 159 | 160 | unset EPOCHSECONDS 161 | zmodload -F zsh/datetime p:EPOCHSECONDS 162 | zmodload -Fe zsh/datetime +p:EPOCHSECONDS 163 | 0:unsetting a global parameter allows feature parameter to be enabled 164 | 165 | zmodload -F zsh/datetime -b:strftime -p:EPOCHSECONDS 166 | zmodload zsh/datetime 167 | zmodload -lF zsh/datetime 168 | 0:zmodload with no -F enables all features 169 | >+b:strftime 170 | >+p:EPOCHSECONDS 171 | >+p:EPOCHREALTIME 172 | >+p:epochtime 173 | -------------------------------------------------------------------------------- /Test/V05styles.ztst: -------------------------------------------------------------------------------- 1 | %prep 2 | 3 | # Test the use of styles, if the zsh/zutil module is available. 4 | 5 | if ! zmodload zsh/zutil 2>/dev/null; then 6 | ZTST_unimplemented="can't load the zsh/zutil module for testing" 7 | fi 8 | 9 | %test 10 | zstyle :random:stuff any-old-style with any old value 11 | zstyle :randomly:chosen some-other-style I can go on and on 12 | zstyle -d 13 | zstyle 14 | 0:zstyle -d restores a pristine state 15 | 16 | # patterns should be ordered by weight, so add in reverse order to check 17 | zstyle ':ztst:context*' scalar-style other-scalar-value 18 | zstyle ':ztst:context:*' scalar-style second-scalar-value 19 | zstyle ':ztst:context:sub1' scalar-style scalar-value 20 | zstyle ':ztst:context:sub1' array-style array value elements 'with spaces' 21 | zstyle ':ztst:context*' boolean-style false 22 | zstyle ':ztst:context:sub1' boolean-style true 23 | 0:defining styles 24 | 25 | # styles are now sorted, but patterns are in order of definition 26 | zstyle 27 | 0:listing styles in default format 28 | >array-style 29 | > :ztst:context:sub1 array value elements 'with spaces' 30 | >boolean-style 31 | > :ztst:context:sub1 true 32 | > :ztst:context* false 33 | >scalar-style 34 | > :ztst:context:sub1 scalar-value 35 | > :ztst:context:* second-scalar-value 36 | > :ztst:context* other-scalar-value 37 | 38 | zstyle -L 39 | 0:listing styles in zstyle format 40 | >zstyle :ztst:context:sub1 array-style array value elements 'with spaces' 41 | >zstyle :ztst:context:sub1 boolean-style true 42 | >zstyle ':ztst:context*' boolean-style false 43 | >zstyle :ztst:context:sub1 scalar-style scalar-value 44 | >zstyle ':ztst:context:*' scalar-style second-scalar-value 45 | >zstyle ':ztst:context*' scalar-style other-scalar-value 46 | 47 | zstyle -b :ztst:context:sub1 boolean-style bool; print $bool 48 | zstyle -t :ztst:context:sub1 boolean-style 49 | 0:boolean test -b/-t + true 50 | >yes 51 | 52 | zstyle -b :ztst:context:sub2 boolean-style bool; print $bool 53 | zstyle -t :ztst:context:sub2 boolean-style 54 | 1:boolean test -b/-t + false 55 | >no 56 | 57 | zstyle -b :ztst:context:sub1 boolean-unset-style bool; print $bool 58 | zstyle -t :ztst:context:sub1 boolean-unset-style 59 | 2:boolean test -b/-t + unset 60 | >no 61 | 62 | zstyle -T :ztst:context:sub1 boolean-style 63 | 0:boolean test -T + true 64 | 65 | zstyle -T :ztst:context:sub2 boolean-style 66 | 1:boolean test -T + false 67 | 68 | zstyle -T :ztst:context:sub1 boolean-unset-style 69 | 0:boolean test -T + unset 70 | 71 | zstyle -s :ztst:context:sub1 scalar-style scalar && print $scalar 72 | zstyle -s :ztst:context:sub2 scalar-style scalar && print $scalar 73 | zstyle -s :ztst:contextual-psychedelia scalar-style scalar && print $scalar 74 | zstyle -s :ztst:contemplative scalar-style scalar || print no match 75 | 0:pattern matching rules 76 | >scalar-value 77 | >second-scalar-value 78 | >other-scalar-value 79 | >no match 80 | 81 | zstyle -s :ztst:context:sub1 array-style scalar + && print $scalar 82 | 0:scalar with separator 83 | >array+value+elements+with spaces 84 | 85 | zstyle -e :ztst:\* eval-style 'reply=($something)' 86 | something=(one two three) 87 | zstyle -a :ztst:eval eval-style array && print -l $array 88 | 0:zstyle -e evaluations 89 | >one 90 | >two 91 | >three 92 | 93 | # pattern ordering on output is not specified, so although in the 94 | # current implementation it's deterministic we shouldn't 95 | # assume it's always the same. Thus we sort the array. 96 | # (It might be a nice touch to order patterns by weight, which is 97 | # the way they are stored for each separate style.) 98 | zstyle -g array && print -l ${(o)array} 99 | 0:retrieving patterns 100 | >:ztst:* 101 | >:ztst:context* 102 | >:ztst:context:* 103 | >:ztst:context:sub1 104 | 105 | zstyle -m :ztst:context:sub1 array-style 'w* *s' 106 | 0:positive pattern match 107 | 108 | zstyle -m :ztst:context:sub1 array-style 'v' 109 | 1:negative pattern match 110 | 111 | zstyle -g array ':ztst:context*' && print -l $array 112 | 0:retrieving styles by pattern 113 | >boolean-style 114 | >scalar-style 115 | 116 | zstyle -g array ':ztst:context:sub1' array-style && print -l $array 117 | 0:retrieving values by pattern and name 118 | >array 119 | >value 120 | >elements 121 | >with spaces 122 | 123 | zstyle -d :ztst:context:sub1 124 | zstyle 125 | 0:deleting styles by pattern only 126 | >boolean-style 127 | > :ztst:context* false 128 | >eval-style 129 | >(eval) :ztst:* 'reply=($something)' 130 | >scalar-style 131 | > :ztst:context:* second-scalar-value 132 | > :ztst:context* other-scalar-value 133 | 134 | zstyle -d :ztst:context\* scalar-style 135 | zstyle 136 | 0:deleting styles by pattern and style name 137 | >boolean-style 138 | > :ztst:context* false 139 | >eval-style 140 | >(eval) :ztst:* 'reply=($something)' 141 | >scalar-style 142 | > :ztst:context:* second-scalar-value 143 | 144 | -------------------------------------------------------------------------------- /Test/V07pcre.ztst: -------------------------------------------------------------------------------- 1 | %prep 2 | 3 | if ! zmodload -F zsh/pcre C:pcre-match 2>/dev/null 4 | then 5 | ZTST_unimplemented="the zsh/pcre module is not available" 6 | return 0 7 | fi 8 | # Load the rest of the builtins 9 | zmodload zsh/pcre 10 | setopt rematch_pcre 11 | # Find a UTF-8 locale. 12 | setopt multibyte 13 | # Don't let LC_* override our choice of locale. 14 | unset -m LC_\* 15 | mb_ok= 16 | langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8 17 | $(locale -a 2>/dev/null | egrep 'utf8|UTF-8')) 18 | for LANG in $langs; do 19 | if [[ é = ? ]]; then 20 | mb_ok=1 21 | break; 22 | fi 23 | done 24 | if [[ -z $mb_ok ]]; then 25 | ZTST_unimplemented="no UTF-8 locale or multibyte mode is not implemented" 26 | else 27 | print -u $ZTST_fd Testing PCRE multibyte with locale $LANG 28 | mkdir multibyte.tmp && cd multibyte.tmp 29 | fi 30 | 31 | %test 32 | 33 | [[ 'foo→bar' =~ .([^[:ascii:]]). ]] 34 | print $MATCH 35 | print $match[1] 36 | 0:Basic non-ASCII regexp matching 37 | >o→b 38 | >→ 39 | 40 | unset match mend 41 | s=$'\u00a0' 42 | [[ $s =~ '^.$' ]] && print OK 43 | [[ A${s}B =~ .(.). && $match[1] == $s ]] && print OK 44 | [[ A${s}${s}B =~ A([^[:ascii:]]*)B && $mend[1] == 3 ]] && print OK 45 | unset s 46 | 0:Raw IMETA characters in input string 47 | >OK 48 | >OK 49 | >OK 50 | 51 | [[ foo =~ f.+ ]] ; print $? 52 | [[ foo =~ x.+ ]] ; print $? 53 | [[ ! foo =~ f.+ ]] ; print $? 54 | [[ ! foo =~ x.+ ]] ; print $? 55 | [[ foo =~ f.+ && bar =~ b.+ ]] ; print $? 56 | [[ foo =~ x.+ && bar =~ b.+ ]] ; print $? 57 | [[ foo =~ f.+ && bar =~ x.+ ]] ; print $? 58 | [[ ! foo =~ f.+ && bar =~ b.+ ]] ; print $? 59 | [[ foo =~ f.+ && ! bar =~ b.+ ]] ; print $? 60 | [[ ! ( foo =~ f.+ && bar =~ b.+ ) ]] ; print $? 61 | [[ ! foo =~ x.+ && bar =~ b.+ ]] ; print $? 62 | [[ foo =~ x.+ && ! bar =~ b.+ ]] ; print $? 63 | [[ ! ( foo =~ x.+ && bar =~ b.+ ) ]] ; print $? 64 | 0:Regex result inversion detection 65 | >0 66 | >1 67 | >1 68 | >0 69 | >0 70 | >1 71 | >1 72 | >1 73 | >1 74 | >1 75 | >0 76 | >1 77 | >0 78 | 79 | # Note that PCRE_ANCHORED only means anchored at the start 80 | # Also note that we don't unset MATCH/match on failed match (and it's an 81 | # open issue as to whether or not we should) 82 | pcre_compile '.(→.)' 83 | pcre_match foo→bar 84 | print $? $MATCH $match ; unset MATCH match 85 | pcre_match foo.bar 86 | print $? $MATCH $match ; unset MATCH match 87 | pcre_match foo†bar 88 | print $? $MATCH $match ; unset MATCH match 89 | pcre_match foo→†ar 90 | print $? $MATCH $match ; unset MATCH match 91 | pcre_study 92 | pcre_match foo→bar 93 | print $? $MATCH $match ; unset MATCH match 94 | pcre_compile -a '.(→.)' 95 | pcre_match foo→bar 96 | print $? $MATCH $match ; unset MATCH match 97 | pcre_match o→bar 98 | print $? $MATCH $match ; unset MATCH match 99 | pcre_match o→b 100 | print $? $MATCH $match ; unset MATCH match 101 | pcre_compile 'x.(→.)' 102 | pcre_match xo→t 103 | print $? $MATCH $match ; unset MATCH match 104 | pcre_match Xo→t 105 | print $? $MATCH $match ; unset MATCH match 106 | pcre_compile -i 'x.(→.)' 107 | pcre_match xo→t 108 | print $? $MATCH $match ; unset MATCH match 109 | pcre_match Xo→t 110 | print $? $MATCH $match ; unset MATCH match 111 | 0:pcre_compile interface testing: basic, anchored & case-insensitive 112 | >0 o→b →b 113 | >1 114 | >1 115 | >0 o→† →† 116 | >0 o→b →b 117 | >1 118 | >0 o→b →b 119 | >0 o→b →b 120 | >0 xo→t →t 121 | >1 122 | >0 xo→t →t 123 | >0 Xo→t →t 124 | 125 | string="The following zip codes: 78884 90210 99513" 126 | pcre_compile -m "\d{5}" 127 | pcre_match -b -- $string && print "$MATCH; ZPCRE_OP: $ZPCRE_OP" 128 | pcre_match -b -n $ZPCRE_OP[(w)2] -- $string || print failed 129 | print "$MATCH; ZPCRE_OP: $ZPCRE_OP" 130 | 0:pcre_match -b and pcre_match -n 131 | >78884; ZPCRE_OP: 25 30 132 | >90210; ZPCRE_OP: 31 36 133 | 134 | # Subshell because crash on failure 135 | ( setopt re_match_pcre 136 | [[ test.txt =~ '^(.*_)?(test)' ]] 137 | echo $match[2] ) 138 | 0:regression for segmentation fault, workers/38307 139 | >test 140 | -------------------------------------------------------------------------------- /Test/V08zpty.ztst: -------------------------------------------------------------------------------- 1 | # zpty is required by tests of interactive modes of the shell itself. 2 | # This tests some extra things. 3 | 4 | %prep 5 | 6 | if ! zmodload zsh/zpty 2>/dev/null 7 | then 8 | ZTST_unimplemented="the zsh/zpty module is not available" 9 | elif [[ $OSTYPE = cygwin ]]; then 10 | ZTST_unimplemented="the zsh/zpty module does not work on Cygwin" 11 | fi 12 | 13 | %test 14 | 15 | zpty cat cat 16 | zpty -w cat a line of text 17 | var= 18 | zpty -r cat var && print -r -- ${var%%$'\r\n'} 19 | zpty -d cat 20 | 0:zpty with a process that does not set up the terminal: internal write 21 | >a line of text 22 | 23 | zpty cat cat 24 | print a line of text | zpty -w cat 25 | var= 26 | zpty -r cat var && print -r -- ${var%%$'\r\n'} 27 | zpty -d cat 28 | 0:zpty with a process that does not set up the terminal: write via stdin 29 | >a line of text 30 | -------------------------------------------------------------------------------- /Test/V09datetime.ztst: -------------------------------------------------------------------------------- 1 | %prep 2 | 3 | if zmodload zsh/datetime 2>/dev/null; then 4 | setopt multibyte 5 | unset LC_ALL 6 | LC_TIME=C 7 | TZ=UTC+0 8 | # It's not clear this skip_extensions is correct, but the 9 | # format in question is causing problems on Solaris. 10 | # We'll revist this after the release. 11 | [[ "$(strftime %^_10B 0)" = " JANUARY" ]] || skip_extensions=1 12 | [[ "$(LC_TIME=ja_JP.UTF-8 strftime %OS 1)" = 一 ]] || skip_japanese=1 13 | else 14 | ZTST_unimplemented="can't load the zsh/datetime module for testing" 15 | fi 16 | 17 | %test 18 | 19 | strftime %y 0 20 | strftime %Y 1000000000 21 | strftime %x 1200000000 22 | strftime %X 1200000001 23 | 0:basic format specifiers 24 | >70 25 | >2001 26 | >01/10/08 27 | >21:20:01 28 | 29 | strftime %-m_%f_%K_%L 1181100000 30 | strftime %6. 0 31 | 0:zsh extensions 32 | >6_6_3_3 33 | >000000 34 | 35 | if [[ $skip_extensions = 1 ]]; then 36 | ZTST_skip="strftime extensions not supported" 37 | elif [[ $skip_japanese = 1 ]]; then 38 | ZTST_skip="Japanese UTF-8 locale not supported" 39 | else 40 | ( 41 | LC_TIME=ja_JP.UTF-8 42 | strftime %Ey 1000000000 43 | strftime %Oy 1000000000 44 | strftime %Ex 1000000000 45 | strftime %OS 1000000000 46 | strftime %03Ey 650000000 47 | ) 48 | fi 49 | 0:alternate format extensions 50 | >13 51 | >一 52 | >平成13年09月09日 53 | >四十 54 | >002 55 | 56 | if [[ $skip_extensions = 1 ]]; then 57 | ZTST_skip="strftime extensions not supported" 58 | else 59 | ( 60 | strftime '%#A' 0 61 | strftime '%^_10B' 0 62 | strftime %03Ey 650000000 63 | strftime %-Oe 0 64 | ) 65 | fi 66 | 0:various extensions 67 | >THURSDAY 68 | > JANUARY 69 | >090 70 | >1 71 | 72 | print -r -- ${(V)"$(strftime $'%Y\0%m\0%d' 100000000)"} 73 | 0:Embedded nulls 74 | >1973^@03^@03 75 | -------------------------------------------------------------------------------- /Test/V10private.ztst: -------------------------------------------------------------------------------- 1 | # Tests for the zsh/param/private module 2 | 3 | %prep 4 | 5 | if ! zmodload zsh/param/private 2>/dev/null; then 6 | ZTST_unimplemented="can't load the zsh/param/private module for testing" 7 | else 8 | # Do not use .tmp here, ztst.zsh will remove it too soon (see %cleanup) 9 | mkdir private.TMP 10 | sed -e 's,# test_zsh_param_private,zmodload zsh/param/private,' < $ZTST_srcdir/B02typeset.ztst > private.TMP/B02 11 | fi 12 | 13 | %test 14 | 15 | (zmodload -u zsh/param/private && zmodload zsh/param/private) 16 | 0:unload and reload the module without crashing 17 | 18 | typeset scalar_test=toplevel 19 | () { 20 | print $scalar_test 21 | private scalar_test 22 | print $+scalar_test 23 | unset scalar_test 24 | print $+scalar_test 25 | } 26 | print $scalar_test 27 | 0:basic scope hiding 28 | >toplevel 29 | >1 30 | >0 31 | >toplevel 32 | 33 | typeset scalar_test=toplevel 34 | print $scalar_test 35 | () { 36 | private scalar_test=function 37 | print $scalar_test 38 | } 39 | print $scalar_test 40 | 0:enter and exit a scope 41 | >toplevel 42 | >function 43 | >toplevel 44 | 45 | print $+unset_test 46 | () { 47 | private unset_test 48 | print $+unset_test 49 | unset_test=setme 50 | print $unset_test 51 | } 52 | print $+unset_test 53 | 0:variable defined only in scope 54 | >0 55 | >1 56 | >setme 57 | >0 58 | 59 | # Depends on zsh-5.0.9 typeset keyword 60 | typeset -a array_test=(top level) 61 | () { 62 | local -Pa array_test=(in function) 63 | () { 64 | private array_test 65 | print $+array_test 66 | } 67 | print $array_test 68 | } 69 | print $array_test 70 | 0:nested scope with different type, correctly restored 71 | >1 72 | >in function 73 | >top level 74 | 75 | typeset -a array_test=(top level) 76 | () { 77 | private array_test 78 | array_test=(in function) 79 | } 80 | 1:type of private may not be changed by assignment 81 | ?(anon):2: array_test: attempt to assign array value to non-array 82 | 83 | typeset -A hash_test=(top level) 84 | () { 85 | setopt localoptions noglob 86 | private hash_test[top] 87 | } 88 | 1:associative array fields may not be private 89 | ?(anon):private:2: hash_test[top]: can't create local array elements 90 | 91 | () { 92 | private path 93 | } 94 | 1:tied params may not be private, part 1 95 | ?(anon):private:1: can't change scope of existing param: path 96 | 97 | () { 98 | private PATH 99 | } 100 | 1:tied params may not be private, part 2 101 | ?(anon):private:1: can't change scope of existing param: PATH 102 | 103 | () { 104 | private -h path 105 | print X$path 106 | } 107 | 0:privates may hide tied paramters 108 | >X 109 | 110 | # Deliberate type mismatch here 111 | typeset -a hash_test=(top level) 112 | typeset -p hash_test 113 | inner () { 114 | private -p hash_test 115 | print ${(t)hash_test} ${(kv)hash_test} 116 | } 117 | outer () { 118 | local -PA hash_test=(in function) 119 | typeset -p hash_test 120 | inner 121 | } 122 | outer 123 | print ${(kv)hash_test} 124 | 0:private hides value from surrounding scope in nested scope 125 | >typeset -a hash_test=( top level ) 126 | >typeset -A hash_test=( in function ) 127 | >typeset -g -a hash_test=( top level ) 128 | >array-local top level 129 | >top level 130 | F:note "typeset" rather than "private" in output from outer 131 | 132 | () { 133 | private -a array_test 134 | local array_test=scalar 135 | } 136 | 1:private cannot be re-declared as local 137 | ?(anon):local:2: array_test: inconsistent type for assignment 138 | 139 | () { 140 | local hash_test=scalar 141 | private -A hash_test 142 | } 143 | 1:local cannot be re-declared as private 144 | ?(anon):private:2: can't change scope of existing param: hash_test 145 | 146 | inner () { 147 | print $+scalar_test 148 | $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test' 149 | } 150 | () { 151 | private -x scalar_test=whaat 152 | $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test' 153 | inner 154 | print Y $scalar_test 155 | } 156 | 0:exported private behaves like a local, part 1 157 | >X whaat 158 | >0 159 | >X whaat 160 | >Y whaat 161 | 162 | inner () { 163 | typeset -p array_test 164 | $ZTST_testdir/../Src/zsh -fc 'print X $array_test' 165 | } 166 | () { 167 | local -Pax array_test=(whaat) 168 | print Y $array_test 169 | $ZTST_testdir/../Src/zsh -fc 'print X $array_test' 170 | inner 171 | } 172 | 0:exported private behaves like a local, part 2 (arrays do not export) 173 | ?inner:typeset:1: no such variable: array_test 174 | >Y whaat 175 | >X 176 | >X 177 | 178 | inner () { 179 | print $+scalar_test 180 | $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test' 181 | } 182 | () { 183 | private scalar_test=whaat 184 | export scalar_test 185 | $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test' 186 | inner 187 | () { 188 | print $+scalar_test 189 | $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test' 190 | } 191 | print Y $scalar_test 192 | } 193 | 0:exported private behaves like a local, part 3 (export does not change scope) 194 | >X whaat 195 | >0 196 | >X whaat 197 | >0 198 | >X whaat 199 | >Y whaat 200 | 201 | typeset -A hash_test=(top level) 202 | () { 203 | local -PA hash_test=(in function) 204 | () { 205 | print X ${(kv)hash_test} 206 | } 207 | print Y ${(kv)hash_test} 208 | } 209 | print ${(kv)hash_test} 210 | 0:privates are not visible in anonymous functions, part 1 211 | >X top level 212 | >Y in function 213 | >top level 214 | 215 | typeset -A hash_test=(top level) 216 | () { 217 | local -PA hash_test=(in function) 218 | () { 219 | print X ${(kv)hash_test} 220 | hash_test[in]=deeper 221 | } 222 | print Y ${(kv)hash_test} 223 | } 224 | print ${(okv)hash_test} 225 | 0:privates are not visible in anonymous functions, part 2 226 | >X top level 227 | >Y in function 228 | >deeper in level top 229 | 230 | typeset -A hash_test=(top level) 231 | () { 232 | local -Pa array_test=(in function) 233 | local -PA hash_test=($array_test) 234 | () { 235 | print X ${(kv)hash_test} 236 | hash_test=(even deeper) 237 | { 238 | array_test+=(${(kv)hash_test}) 239 | } always { 240 | print ${array_test-array_test not set} ${(t)array_test} 241 | } 242 | } 243 | print Y ${(kv)hash_test} Z $array_test 244 | } 245 | print ${(kv)hash_test} ${(t)array_test} 246 | 1:privates are not visible in anonymous functions, part 3 247 | >X top level 248 | >array_test not set 249 | ?(anon):4: array_test: attempt to assign private in nested scope 250 | F:future revision will create a global with this assignment 251 | 252 | typeset -a array_test 253 | typeset -A hash_test=(top level) 254 | () { 255 | local -Pa array_test=(in function) 256 | local -PA hash_test=($array_test) 257 | () { 258 | print X ${(kv)hash_test} 259 | hash_test=(even deeper) 260 | array_test+=(${(kv)hash_test}) 261 | } 262 | print Y ${(kv)hash_test} Z $array_test 263 | } 264 | print ${(kv)hash_test} $array_test 265 | 0:privates are not visible in anonymous functions, part 4 266 | >X top level 267 | >Y in function Z in function 268 | >even deeper even deeper 269 | 270 | typeset -A hash_test=(top level) 271 | () { 272 | local -PA hash_test=(in function) 273 | () { 274 | print X ${(kv)hash_test} 275 | unset hash_test 276 | } 277 | print Y ${(kv)hash_test} 278 | } 279 | print ${(t)hash_test} ${(kv)hash_test} 280 | 0:privates are not visible in anonymous functions, part 5 281 | >X top level 282 | >Y in function 283 | > 284 | 285 | # Subshell because otherwise this silently dumps core when broken 286 | ( () { private SECONDS } ) 287 | 1:special parameters cannot be made private 288 | ?(anon):private: can't change scope of existing param: SECONDS 289 | 290 | () { private -h SECONDS } 291 | 0:private parameter may hide a special parameter 292 | 293 | if (( UID )); then 294 | ZTST_verbose=0 $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh private.TMP/B02 295 | else 296 | ZTST_skip="cannot re-run typeset tests when tests run as superuser" 297 | fi 298 | 0:typeset still works with zsh/param/private module loaded 299 | *>* 300 | *>* 301 | 302 | %clean 303 | 304 | rm -r private.TMP 305 | -------------------------------------------------------------------------------- /Test/V11db_gdbm.ztst: -------------------------------------------------------------------------------- 1 | # Tests for the zsh/param/private module 2 | 3 | %prep 4 | 5 | module_path=( `pwd`/Modules ) 6 | modname="zdharma/zgdbm" 7 | #modname="zsh/db/gdbm" 8 | dbfile=db.gdbm 9 | if ! zmodload $modname ; then 10 | ZTST_unimplemented="can't load $modname module for testing" 11 | fi 12 | rm -f db.gdbm 13 | 14 | %test 15 | 16 | (zmodload -u $modname && zmodload $modname) 17 | 0:unload and reload the module without crashing 18 | 19 | ztie -d db/gdbm -f $dbfile dbase 20 | zuntie dbase 21 | 0:create the database 22 | 23 | ztie -r -d db/gdbm -f $dbfile dbase 24 | zuntie -u dbase 25 | 0:open the database read-only 26 | 27 | ztie -d db/gdbm -f $dbfile dbase 28 | dbase[testkey]=testdata 29 | zuntie dbase 30 | ztie -r -d db/gdbm -f $dbfile dbase 31 | echo $dbase[testkey] 32 | zuntie -u dbase 33 | 0:store key in database 34 | >testdata 35 | 36 | ztie -d db/gdbm -f $dbfile dbase2 37 | unset 'dbase2[testkey]' 38 | zuntie dbase2 39 | ztie -d db/gdbm -f $dbfile dbase 40 | echo $dbase[testkey] 41 | zuntie dbase 42 | 0:remove key from database (different variables) 43 | > 44 | 45 | ztie -d db/gdbm -f $dbfile dbase 46 | dbase[testkey]=testdata 47 | zuntie dbase 48 | ztie -r -d db/gdbm -f $dbfile dbase 49 | echo $dbase[testkey] 50 | zuntie -u dbase 51 | ztie -d db/gdbm -f $dbfile dbase 52 | unset 'dbase[testkey]' 53 | zuntie dbase 54 | ztie -r -d db/gdbm -f $dbfile dbase 55 | echo $dbase[testkey] 56 | zuntie -u dbase 57 | 0:store & remove key from database (the same variables) 58 | >testdata 59 | > 60 | 61 | ztie -d db/gdbm -f $dbfile dbase 62 | dbase[testkey]=testdata 63 | dbase[testkey2]=$dbase[testkey] 64 | dbase[testkey3]=$dbase[testkey]x$dbase[testkey2] 65 | zuntie dbase 66 | ztie -d db/gdbm -f $dbfile dbase 67 | echo $dbase[testkey] 68 | echo $dbase[testkey2] 69 | echo $dbase[testkey3] 70 | zuntie dbase 71 | 0:store 2 keys fetching 1st 72 | >testdata 73 | >testdata 74 | >testdataxtestdata 75 | 76 | ztie -d db/gdbm -f $dbfile dbase 77 | val=$dbase[testkey2] 78 | unset 'dbase[testkey2]' 79 | echo $val 80 | zuntie dbase 81 | 0:unset key that was fetched 82 | >testdata 83 | 84 | ztie -r -d db/gdbm -f $dbfile dbase 85 | local -a result=( "${(kv)dbase[@]}" ) 86 | print -rl -- "${(o)result[@]}" 87 | zuntie -u dbase 88 | 0:scan read-only tied hash, directly assign local -a 89 | >testdata 90 | >testdataxtestdata 91 | >testkey 92 | >testkey3 93 | 94 | ztie -d db/gdbm -f $dbfile dbase 95 | dbase=( a a ) 96 | print -rl -- "${(kv)dbase[@]}" 97 | zuntie dbase 98 | 0:Use scan directly, read-write mode 99 | >a 100 | >a 101 | 102 | ztie -d db/gdbm -f $dbfile dbase 103 | dbase=( a b c d ) 104 | zuntie dbase 105 | ztie -d db/gdbm -f $dbfile dbase 106 | result=( "${(kv)dbase[@]}" ) 107 | print -rl -- "${(o)result[@]}" 108 | zuntie dbase 109 | 0:replace hash / database, scan 110 | >a 111 | >b 112 | >c 113 | >d 114 | 115 | ztie -d db/gdbm -f $dbfile dbase 116 | local -a arr 117 | arr=( "${dbase[@]}" ) 118 | print -rl -- "${(o)arr[@]}" 119 | zuntie dbase 120 | 0:scan with no (kv) 121 | >b 122 | >d 123 | 124 | ztie -d db/gdbm -f $dbfile dbase 125 | result=( "${(k)dbase[@]}" ) 126 | print -rl -- "${(o)result[@]}" 127 | zuntie dbase 128 | 0:scan with keys only (k) 129 | >a 130 | >c 131 | 132 | ztie -d db/gdbm -f $dbfile dbase 133 | result=( "${(v)dbase[@]}" ) 134 | print -rl -- "${(o)result[@]}" 135 | zuntie dbase 136 | 0:scan with keys only explicit (v) 137 | >b 138 | >d 139 | 140 | rm -f $dbfile 141 | ztie -r -d db/gdbm -f $dbfile dbase 2>/dev/null 142 | 1:read-only open non-existent database 143 | 144 | ztie -d db/gdbm -f $dbfile dbase 145 | dbase+=( a b ) 146 | echo $dbase[a] 147 | zuntie dbase 148 | ztie -r -d db/gdbm -f $dbfile dbase 149 | echo $dbase[a] 150 | result=( "${(kv)dbase[@]}" ) 151 | print -rl -- "${(o)result[@]}" 152 | zuntie -u dbase 153 | ztie -d db/gdbm -f $dbfile dbase 154 | dbase+=( c d ) 155 | echo $dbase[a] 156 | echo $dbase[c] 157 | result=( "${(kv)dbase[@]}" ) 158 | print -rl -- "${(o)result[@]}" 159 | zuntie dbase 160 | ztie -r -d db/gdbm -f $dbfile dbase 161 | echo $dbase[a] 162 | echo $dbase[c] 163 | result=( "${(kv)dbase[@]}" ) 164 | print -rl -- "${(o)result[@]}" 165 | zuntie -u dbase 166 | 0:Append with +=( ), also with existing data, also (kv) scan 167 | >b 168 | >b 169 | >a 170 | >b 171 | >b 172 | >d 173 | >a 174 | >b 175 | >c 176 | >d 177 | >b 178 | >d 179 | >a 180 | >b 181 | >c 182 | >d 183 | 184 | ztie -d db/gdbm -f $dbfile dbase 185 | echo ${(t)dbase} 186 | zuntie dbase 187 | 0:Type of tied parameter 188 | >association-special 189 | 190 | typeset -ga dbase 191 | ztie -d db/gdbm -f $dbfile dbase 192 | echo ${(t)dbase} 193 | zuntie dbase 194 | 0:Type of tied parameter, with preceding unset 195 | >association-special 196 | 197 | local -a dbase 198 | ztie -d db/gdbm -f $dbfile dbase 199 | echo ${(t)dbase} 200 | zuntie dbase 201 | 0:Type of tied parameter, with local parameter already existing 202 | >association-local-special 203 | 204 | local -a dbase 205 | dbase=( fromarray ) 206 | () { 207 | local -a dbase 208 | ztie -d db/gdbm -f $dbfile dbase 209 | echo ${(t)dbase} 210 | zuntie dbase 211 | } 212 | echo $dbase[1] 213 | ztie -d db/gdbm -f $dbfile dbase2 214 | echo "Can connect, so untie happened:" $dbase2[a] 215 | zuntie dbase2 216 | 0:Test of automatic untie (use of local scope) and of scoping 217 | >association-local-special 218 | >fromarray 219 | >Can connect, so untie happened: b 220 | 221 | echo $zgdbm_tied ${#zgdbm_tied} 222 | ztie -r -d db/gdbm -f $dbfile dbase 223 | echo $zgdbm_tied ${#zgdbm_tied} 224 | ztie -d db/gdbm -f ${dbfile}2 dbase2 225 | echo $zgdbm_tied ${#zgdbm_tied} 226 | zuntie -u dbase 227 | echo $zgdbm_tied ${#zgdbm_tied} 228 | zuntie dbase2 229 | echo $zgdbm_tied ${#zgdbm_tied} 230 | 0:zgdbm_tied parameter 231 | >0 232 | >dbase 1 233 | >dbase dbase2 2 234 | >dbase2 1 235 | >0 236 | 237 | unset zgdbm_tied 2>/dev/null 238 | 1:unset of read-only zgdbm_tied parameter 239 | 240 | ztie -d db/gdbm -f $dbfile dbase 241 | dbase[漢字]=漢字 242 | echo $dbase[漢字] 243 | zuntie dbase 244 | ztie -r -d db/gdbm -f $dbfile dbase 245 | echo $dbase[漢字] 246 | zuntie -u dbase 247 | 0:Unicode test 248 | >漢字 249 | >漢字 250 | 251 | key="ab"$'\0'"ef" 252 | ztie -d db/gdbm -f $dbfile dbase 253 | dbase[$key]=value 254 | echo $dbase[$key] 255 | zuntie dbase 256 | ztie -r -d db/gdbm -f $dbfile dbase 257 | echo $dbase[$key] 258 | zuntie -u dbase 259 | ztie -d db/gdbm -f $dbfile dbase 260 | dbase[$key]=$key 261 | zuntie dbase 262 | ztie -d db/gdbm -f $dbfile dbase 263 | [[ "$dbase[$key]" = "$key" ]] && echo correct 264 | zuntie dbase 265 | 0:Metafication of $'\0' 266 | >value 267 | >value 268 | >correct 269 | 270 | ztie -d db/gdbm -f $dbfile dbase 271 | dbase=( 漢字 漢字 ) 272 | echo $dbase[漢字] 273 | zuntie dbase 274 | ztie -d db/gdbm -f $dbfile dbase 275 | echo $dbase[漢字] 276 | zuntie dbase 277 | key="ab"$'\0'"ef" 278 | ztie -d db/gdbm -f $dbfile dbase 279 | dbase+=( $key $key ) 280 | zuntie dbase 281 | ztie -r -d db/gdbm -f $dbfile dbase 282 | [[ "$dbase[$key]" = "$key" ]] && echo correct 283 | zuntie -u dbase 284 | 0:Unicode & metafication test, different hash access 285 | >漢字 286 | >漢字 287 | >correct 288 | 289 | ztie -d db/gdbm -f $dbfile dbase 290 | dbase=( 漢字 漢字 ) 291 | zuntie dbase 292 | ztie -d db/gdbm -f $dbfile dbase 293 | noglob print -rl ${(kv)dbase[@]} 294 | zuntie dbase 295 | 0:Hash scanning and metafication 296 | >漢字 297 | >漢字 298 | 299 | ztie -d db/gdbm -f $dbfile dbase 300 | noglob print -rl ${(okv)dbase[@]} 301 | zuntie dbase 302 | 0:Sorted hash scanning and metafication 303 | >漢字 304 | >漢字 305 | 306 | ztie -d db/gdbm -f $dbfile dbase 307 | zgdbmpath dbase 308 | [[ $REPLY = */Test/db.gdbm ]] && echo correct 309 | zuntie dbase 310 | ztie -r -d db/gdbm -f $dbfile dbase 311 | zgdbmpath dbase 312 | [[ $REPLY = */Test/db.gdbm ]] && echo correct 313 | zuntie -u dbase 314 | 0:zgdbmpath builtin 315 | >correct 316 | >correct 317 | 318 | ztie -d db/gdbm -f $dbfile dbase 319 | dbase[testkey]=value1 320 | fun() { while read line; do echo $line; done } 321 | eval "dbase[testkey]=value2" | fun 322 | echo $dbase[testkey] 323 | zgdbmclear dbase testkey 324 | echo $dbase[testkey] 325 | 0:Test store in forked Zsh 326 | >value1 327 | >value2 328 | 329 | %clean 330 | 331 | rm -f ${dbfile}* 332 | -------------------------------------------------------------------------------- /Test/W01history.ztst: -------------------------------------------------------------------------------- 1 | # Tests for BANG_HIST replacements 2 | 3 | %prep 4 | 5 | if [[ -t 0 ]]; then print -u $ZTST_fd History tests write to /dev/tty; fi 6 | 7 | %test 8 | 9 | $ZTST_testdir/../Src/zsh -fis <<<' 10 | print one two three four five six seven eight nine ten 11 | print !:$ !:10 !:9 !:1 !:0 12 | print one two three four five six seven eight nine ten 13 | print !:0-$ !:1-2 14 | ' 2>/dev/null 15 | 0:History word references 16 | >one two three four five six seven eight nine ten 17 | >ten ten nine one print 18 | >one two three four five six seven eight nine ten 19 | >print one two three four five six seven eight nine ten one two 20 | 21 | $ZTST_testdir/../Src/zsh -fis <<<' 22 | print line one of an arbitrary series 23 | print issue two for some mystery sequence 24 | print !-1:5-$ 25 | print !1:2 26 | print !2:2 27 | print !-3:1-$ 28 | ' 2>/dev/null 29 | 0:History line numbering 30 | >line one of an arbitrary series 31 | >issue two for some mystery sequence 32 | >mystery sequence 33 | >one 34 | >two 35 | >mystery sequence 36 | 37 | $ZTST_testdir/../Src/zsh -fis <<<' 38 | print All metaphor, Malachi, stilts and all 39 | print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/ 40 | print !1:2:& 41 | print -l !1:2-3:gs/a/o/ 42 | ' 2>/dev/null 43 | 0:History substitution 44 | >All metaphor, Malachi, stilts and all 45 | >metaphor? shmetaphor! 46 | >metaphor! 47 | >metophor, 48 | >Molochi, 49 | 50 | $ZTST_testdir/../Src/zsh -fis <<<' 51 | echo foo bar 52 | echo $(!!) again 53 | echo more $( !! )' 2>/dev/null 54 | 0:Regression test for history references in command substitution 55 | >foo bar 56 | >foo bar again 57 | >more foo bar again 58 | *?* 59 | F:Check that a history bug introduced by workers/34160 is working again. 60 | # Discarded line of error output consumes prompts printed by "zsh -i". 61 | -------------------------------------------------------------------------------- /Test/comptest: -------------------------------------------------------------------------------- 1 | comptestinit () { 2 | setopt extendedglob 3 | [[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules ) 4 | fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/) 5 | $ZTST_srcdir/../Completion 6 | $ZTST_srcdir/../Completion/*/*~*/CVS(/) ) 7 | 8 | zmodload zsh/zpty || return $? 9 | 10 | comptest_zsh=${ZSH:-zsh} 11 | comptest_keymap=e 12 | 13 | while getopts vz: opt; do 14 | case $opt in 15 | z) comptest_zsh="$OPTARG";; 16 | v) comptest_keymap="v";; 17 | esac 18 | done 19 | (( OPTIND > 1 )) && shift $(( OPTIND - 1 )) 20 | 21 | export PS1="" 22 | zpty zsh "$comptest_zsh -f +Z" 23 | 24 | zpty -r zsh log1 "**" || { 25 | print "first prompt hasn't appeared." 26 | return 1 27 | } 28 | 29 | comptesteval \ 30 | "export LC_ALL=${ZSH_TEST_LANG:-C}" \ 31 | "emulate -R zsh" \ 32 | "export ZDOTDIR=$ZTST_testdir" \ 33 | "module_path=( $module_path )" \ 34 | "fpath=( $fpath )" \ 35 | "bindkey -$comptest_keymap" \ 36 | 'LISTMAX=10000000 37 | stty 38400 columns 80 rows 24 tabs -icanon -iexten 38 | TERM=vt100 39 | KEYTIMEOUT=1 40 | setopt zle 41 | autoload -U compinit 42 | compinit -u 43 | zstyle ":completion:*:default" list-colors "no=" "fi=" "di=" "ln=" "pi=" "so=" "bd=" "cd=" "ex=" "mi=" "tc=" "sp=" "lc=" "ec=\n" "rc=" 44 | zstyle ":completion:*" group-name "" 45 | zstyle ":completion:*:messages" format "%d 46 | " 47 | zstyle ":completion:*:descriptions" format "%d 48 | " 49 | zstyle ":completion:*:options" verbose yes 50 | zstyle ":completion:*:values" verbose yes 51 | setopt noalwayslastprompt listrowsfirst completeinword 52 | zmodload zsh/complist 53 | expand-or-complete-with-report () { 54 | print -lr "" 55 | zle expand-or-complete 56 | print -lr - "$LBUFFER" "$RBUFFER" 57 | zle clear-screen 58 | zle -R 59 | } 60 | list-choices-with-report () { 61 | print -lr "" 62 | zle list-choices 63 | zle clear-screen 64 | zle -R 65 | } 66 | comp-finish () { 67 | print "" 68 | zle kill-whole-line 69 | zle clear-screen 70 | zle -R 71 | } 72 | zle-finish () { 73 | local buffer="$BUFFER" cursor="$CURSOR" mark="$MARK" 74 | (( region_active)) || unset mark 75 | BUFFER="" 76 | zle -I 77 | zle clear-screen 78 | zle redisplay 79 | print -lr "" "BUFFER: $buffer" "CURSOR: $cursor" 80 | (( $+mark )) && print -lr "MARK: $mark" 81 | zle accept-line 82 | } 83 | zle -N expand-or-complete-with-report 84 | zle -N list-choices-with-report 85 | zle -N comp-finish 86 | zle -N zle-finish 87 | bindkey "^I" expand-or-complete-with-report 88 | bindkey "^D" list-choices-with-report 89 | bindkey "^Z" comp-finish 90 | bindkey "^X" zle-finish 91 | bindkey -a "^X" zle-finish 92 | ' 93 | } 94 | 95 | zpty_flush() { 96 | local junk 97 | if zpty -r -t zsh junk \*; then 98 | (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}" 99 | while zpty -r -t zsh junk \* ; do 100 | (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}" 101 | done 102 | (( ZTST_verbose > 2 )) && print -u $ZTST_fd '' 103 | fi 104 | } 105 | 106 | zpty_run() { 107 | zpty -w zsh "$*" 108 | zpty -r -m zsh log "**" || { 109 | print "prompt hasn't appeared." 110 | return 1 111 | } 112 | } 113 | 114 | comptesteval () { 115 | local tmp=/tmp/comptest.$$ 116 | 117 | print -lr - "$@" > $tmp 118 | # zpty_flush Before comptesteval 119 | zpty -w zsh ". $tmp" 120 | zpty -r -m zsh log_eval "**" || { 121 | print "prompt hasn't appeared." 122 | return 1 123 | } 124 | zpty_flush After comptesteval 125 | rm $tmp 126 | } 127 | 128 | comptest () { 129 | input="$*" 130 | zpty -n -w zsh "$input"$'\C-Z' 131 | zpty -r -m zsh log "***" || { 132 | print "failed to invoke finish widget." 133 | return 1 134 | } 135 | 136 | logs=(${(s::)log}) 137 | shift logs 138 | 139 | for log in "$logs[@]"; do 140 | if [[ "$log" = (#b)*$''(*)$'\r\n'(*)$''* ]]; then 141 | print -lr "line: {$match[1]}{$match[2]}" 142 | fi 143 | while (( ${(N)log#*(#b)(<(??)>(*)|(*)|(*)|(*)|(*))} )); do 144 | log="${log[$mend[1]+1,-1]}" 145 | if (( 0 <= $mbegin[2] )); then 146 | if [[ $match[2] != TC && $match[3] != \ # ]]; then 147 | print -lr "$match[2]:{${match[3]%${(%):-%E}}}" 148 | fi 149 | elif (( 0 <= $mbegin[4] )); then 150 | print -lr "DESCRIPTION:{$match[4]}" 151 | elif (( 0 <= $mbegin[5] )); then 152 | print -lr "MESSAGE:{$match[5]}" 153 | elif (( 0 <= $mbegin[6] )); then 154 | print -lr "COMPADD:{${${match[6]}//[$'\r\n']/}}" 155 | elif (( 0 <= $mbegin[7] )); then 156 | print -lr "INSERT_POSITIONS:{${${match[7]}//[$'\r\n']/}}" 157 | fi 158 | done 159 | done 160 | } 161 | 162 | zletest () { 163 | local first=0 164 | for input; do 165 | # zpty_flush Before zletest 166 | # sleep for $KEYTIMEOUT 167 | (( first++ )) && { sleep 2 & } | read -t 0.011 -u 0 -k 1 168 | zpty -n -w zsh "$input" 169 | done 170 | zpty -n -w zsh $'\C-X' 171 | zpty -r -m zsh log "***" || { 172 | print "failed to invoke finish widget." 173 | return 1 174 | } 175 | # zpty_flush After zletest 176 | print -lr "${(@)${(@ps:\r\n:)log##*}[2,-2]}" 177 | } 178 | -------------------------------------------------------------------------------- /Test/runtests.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh -f 2 | 3 | emulate zsh 4 | 5 | # Run all specified tests, keeping count of which succeeded. 6 | # The reason for this extra layer above the test script is to 7 | # protect from catastrophic failure of an individual test. 8 | # We could probably do that with subshells instead. 9 | 10 | integer success failure skipped retval 11 | for file in "${(f)ZTST_testlist}"; do 12 | $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file 13 | retval=$? 14 | if (( $retval == 2 )); then 15 | (( skipped++ )) 16 | elif (( $retval )); then 17 | (( failure++ )) 18 | else 19 | (( success++ )) 20 | fi 21 | done 22 | print "************************************** 23 | $success successful test script${${success:#1}:+s}, \ 24 | $failure failure${${failure:#1}:+s}, \ 25 | $skipped skipped 26 | **************************************" 27 | return $(( failure ? 1 : 0 )) 28 | -------------------------------------------------------------------------------- /Util/preconfig: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | find . -name .git -prune -o -name '?*.*' -prune -o -name .preconfig -print | ( 4 | while read -r pre; do 5 | cmd=$(echo "${pre}" | sed 's,^,cd ,;s,/\([^/]*\)$, \&\& ./\1,') 6 | echo >&2 "${cmd}" 7 | if (eval "${cmd}"); then :; else 8 | echo "$0: ${pre} failed (status $?)" 9 | exit 1 10 | fi 11 | done 12 | ) 13 | 14 | exit 0 15 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | # Local additions to Autoconf macros. 2 | # Copyright (C) 1992, 1994 Free Software Foundation, Inc. 3 | # Francois Pinard , 1992. 4 | 5 | # @defmac fp_PROG_CC_STDC 6 | # @maindex PROG_CC_STDC 7 | # @ovindex CC 8 | # If the C compiler in not in ANSI C mode by default, try to add an option 9 | # to output variable @code{CC} to make it so. This macro tries various 10 | # options that select ANSI C on some system or another. It considers the 11 | # compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and 12 | # handles function prototypes correctly. 13 | # 14 | # If you use this macro, you should check after calling it whether the C 15 | # compiler has been set to accept ANSI C; if not, the shell variable 16 | # @code{fp_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source 17 | # code in ANSI C, you can make an un-ANSIfied copy of it by using the 18 | # program @code{ansi2knr}, which comes with Ghostscript. 19 | # @end defmac 20 | 21 | define(fp_PROG_CC_STDC, 22 | [AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, 23 | fp_cv_prog_cc_stdc, 24 | [fp_cv_prog_cc_stdc=no 25 | ac_save_CFLAGS="$CFLAGS" 26 | # Don't try gcc -ansi; that turns off useful extensions and 27 | # breaks some systems' header files. 28 | # AIX -qlanglvl=ansi 29 | # Ultrix and OSF/1 -std1 30 | # HP-UX -Ae or -Aa -D_HPUX_SOURCE 31 | # SVR4 -Xc 32 | # For HP-UX, we try -Ae first; this turns on ANSI but also extensions, 33 | # as well as defining _HPUX_SOURCE, and we can then use long long. 34 | # We keep the old version for backward compatibility. 35 | for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" -Xc 36 | do 37 | CFLAGS="$ac_save_CFLAGS $ac_arg" 38 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 39 | [#ifndef __STDC__ 40 | choke me 41 | #endif 42 | ]], [[int test (int i, double x); 43 | struct s1 {int (*f) (int a);}; 44 | struct s2 {int (*f) (double a);};]])], 45 | [fp_cv_prog_cc_stdc="$ac_arg"; break],[]) 46 | done 47 | CFLAGS="$ac_save_CFLAGS" 48 | ]) 49 | case "x$fp_cv_prog_cc_stdc" in 50 | x|xno) ;; 51 | *) CC="$CC $fp_cv_prog_cc_stdc" ;; 52 | esac 53 | ]) 54 | 55 | AC_DEFUN(AC_PROG_LN, 56 | [AC_MSG_CHECKING(whether ln works) 57 | AC_CACHE_VAL(ac_cv_prog_LN, 58 | [rm -f conftestdata conftestlink 59 | echo > conftestdata 60 | if ln conftestdata conftestlink 2>/dev/null 61 | then 62 | rm -f conftestdata conftestlink 63 | ac_cv_prog_LN="ln" 64 | else 65 | rm -f conftestdata 66 | ac_cv_prog_LN="cp" 67 | fi])dnl 68 | LN="$ac_cv_prog_LN" 69 | if test "$ac_cv_prog_LN" = "ln"; then 70 | AC_MSG_RESULT(yes) 71 | else 72 | AC_MSG_RESULT(no) 73 | fi 74 | AC_SUBST(LN)dnl 75 | ]) 76 | 77 | builtin(include, aczsh.m4) 78 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | Scripts/install.sh -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Original author: Noah Friedman 7 | # Created: 1993-05-16 8 | # Public domain. 9 | # 10 | # This file is maintained in Automake, please report 11 | # bugs to or send patches to 12 | # . 13 | 14 | nl=' 15 | ' 16 | IFS=" "" $nl" 17 | errstatus=0 18 | dirmode=755 19 | 20 | usage="\ 21 | Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... 22 | Create each directory DIR (with mode MODE, if specified), including all 23 | leading file name components. 24 | Report bugs to ." 25 | 26 | # process command line arguments 27 | while test $# -gt 0 ; do 28 | case $1 in 29 | -h | --help | --h*) # -h for help 30 | echo "$usage" 31 | exit $? 32 | ;; 33 | -m) # -m PERM arg 34 | shift 35 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 36 | dirmode=$1 37 | shift 38 | ;; 39 | --version) 40 | echo "$0 $scriptversion" 41 | exit $? 42 | ;; 43 | --) # stop option processing 44 | shift 45 | break 46 | ;; 47 | -*) # unknown option 48 | echo "$usage" 1>&2 49 | exit 1 50 | ;; 51 | *) # first non-opt arg 52 | break 53 | ;; 54 | esac 55 | done 56 | 57 | for file 58 | do 59 | if test -d "$file"; then 60 | shift 61 | else 62 | break 63 | fi 64 | done 65 | 66 | case $# in 67 | 0) exit 0 ;; 68 | esac 69 | 70 | # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and 71 | # mkdir -p a/c at the same time, both will detect that a is missing, 72 | # one will create a, then the other will try to create a and die with 73 | # a "File exists" error. This is a problem when calling mkinstalldirs 74 | # from a parallel make. We use --version in the probe to restrict 75 | # ourselves to GNU mkdir, which is thread-safe. 76 | case $dirmode in 77 | '') 78 | if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then 79 | echo "mkdir -p -- $*" 80 | exec mkdir -p -- "$@" 81 | else 82 | # On NextStep and OpenStep, the 'mkdir' command does not 83 | # recognize any option. It will interpret all options as 84 | # directories to create, and then abort because '.' already 85 | # exists. 86 | test -d ./-p && rmdir ./-p 87 | test -d ./--version && rmdir ./--version 88 | fi 89 | ;; 90 | *) 91 | if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && 92 | test ! -d ./--version; then 93 | echo "mkdir -m $dirmode -p -- $*" 94 | exec mkdir -m "$dirmode" -p -- "$@" 95 | else 96 | # Clean up after NextStep and OpenStep mkdir. 97 | for d in ./-m ./-p ./--version "./$dirmode"; 98 | do 99 | test -d $d && rmdir $d 100 | done 101 | fi 102 | ;; 103 | esac 104 | 105 | for file 106 | do 107 | case $file in 108 | /*) pathcomp=/ ;; 109 | *) pathcomp= ;; 110 | esac 111 | oIFS=$IFS 112 | IFS=/ 113 | set fnord $file 114 | shift 115 | IFS=$oIFS 116 | 117 | for d 118 | do 119 | test "x$d" = x && continue 120 | 121 | pathcomp=$pathcomp$d 122 | case $pathcomp in 123 | -*) pathcomp=./$pathcomp ;; 124 | esac 125 | 126 | if test ! -d "$pathcomp"; then 127 | echo "mkdir $pathcomp" 128 | 129 | mkdir "$pathcomp" || lasterr=$? 130 | 131 | if test ! -d "$pathcomp"; then 132 | errstatus=$lasterr 133 | else 134 | if test ! -z "$dirmode"; then 135 | echo "chmod $dirmode $pathcomp" 136 | lasterr= 137 | chmod "$dirmode" "$pathcomp" || lasterr=$? 138 | 139 | if test ! -z "$lasterr"; then 140 | errstatus=$lasterr 141 | fi 142 | fi 143 | fi 144 | fi 145 | 146 | pathcomp=$pathcomp/ 147 | done 148 | done 149 | 150 | exit $errstatus 151 | 152 | # Local Variables: 153 | # mode: shell-script 154 | # sh-indentation: 2 155 | # eval: (add-hook 'write-file-hooks 'time-stamp) 156 | # time-stamp-start: "scriptversion=" 157 | # time-stamp-format: "%:y-%02m-%02d.%02H" 158 | # time-stamp-time-zone: "UTC" 159 | # time-stamp-end: "; # UTC" 160 | # End: 161 | -------------------------------------------------------------------------------- /stamp-h.in: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------