| 1 |
## oils_failures_allowed: 0
|
| 2 |
## compare_shells: bash zsh mksh dash ash
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
type while cd
|
| 7 |
|
| 8 |
## STDOUT:
|
| 9 |
while is a shell keyword
|
| 10 |
cd is a shell builtin
|
| 11 |
## END
|
| 12 |
## OK zsh/mksh STDOUT:
|
| 13 |
while is a reserved word
|
| 14 |
cd is a shell builtin
|
| 15 |
## END
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
mkdir -p _tmp
|
| 20 |
shopt -s expand_aliases || true # bash
|
| 21 |
|
| 22 |
alias ll='ls -l'
|
| 23 |
|
| 24 |
touch _tmp/date
|
| 25 |
chmod +x _tmp/date
|
| 26 |
PATH=_tmp:/bin
|
| 27 |
|
| 28 |
normalize() {
|
| 29 |
# ignore quotes and backticks
|
| 30 |
# bash prints a left backtick
|
| 31 |
quotes='"`'\'
|
| 32 |
sed \
|
| 33 |
-e "s/[$quotes]//g" \
|
| 34 |
-e 's/shell function/function/' \
|
| 35 |
-e 's/is aliased to/is an alias for/'
|
| 36 |
}
|
| 37 |
|
| 38 |
type ll date | normalize
|
| 39 |
|
| 40 |
# Note: both procs and funcs go in var namespace? So they don't respond to
|
| 41 |
# 'type'?
|
| 42 |
|
| 43 |
## STDOUT:
|
| 44 |
ll is an alias for ls -l
|
| 45 |
date is _tmp/date
|
| 46 |
## END
|
| 47 |
## BUG mksh STDOUT:
|
| 48 |
ll is an alias for ls -l
|
| 49 |
date is a tracked alias for _tmp/date
|
| 50 |
## END
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
mkdir -p _tmp
|
| 55 |
touch _tmp/file _tmp/ex
|
| 56 |
chmod +x _tmp/ex
|
| 57 |
|
| 58 |
type _tmp/file _tmp/ex
|
| 59 |
|
| 60 |
# dash and ash don't care if it's executable
|
| 61 |
# mksh
|
| 62 |
|
| 63 |
## status: 1
|
| 64 |
## STDOUT:
|
| 65 |
_tmp/ex is _tmp/ex
|
| 66 |
## END
|
| 67 |
|
| 68 |
## OK mksh/zsh STDOUT:
|
| 69 |
_tmp/file not found
|
| 70 |
_tmp/ex is _tmp/ex
|
| 71 |
## END
|
| 72 |
|
| 73 |
## BUG dash/ash status: 0
|
| 74 |
## BUG dash/ash STDOUT:
|
| 75 |
_tmp/file is _tmp/file
|
| 76 |
_tmp/ex is _tmp/ex
|
| 77 |
## END
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
type zz 2>err.txt
|
| 82 |
echo status=$?
|
| 83 |
|
| 84 |
# for bash and OSH: print to stderr
|
| 85 |
fgrep -o 'zz: not found' err.txt || true
|
| 86 |
|
| 87 |
# zsh and mksh behave the same - status 1
|
| 88 |
# dash and ash behave the same - status 127
|
| 89 |
|
| 90 |
## STDOUT:
|
| 91 |
status=1
|
| 92 |
zz: not found
|
| 93 |
## END
|
| 94 |
|
| 95 |
## OK mksh/zsh STDOUT:
|
| 96 |
zz not found
|
| 97 |
status=1
|
| 98 |
## END
|
| 99 |
## STDERR:
|
| 100 |
## END
|
| 101 |
|
| 102 |
## BUG dash/ash STDOUT:
|
| 103 |
zz: not found
|
| 104 |
status=127
|
| 105 |
## END
|
| 106 |
## BUG dash/ash STDERR:
|
| 107 |
## END
|
| 108 |
|
| 109 |
|
| 110 |
type cd
|
| 111 |
type eval
|
| 112 |
type :
|
| 113 |
type true
|
| 114 |
|
| 115 |
echo
|
| 116 |
type export
|
| 117 |
|
| 118 |
## STDOUT:
|
| 119 |
cd is a shell builtin
|
| 120 |
eval is a special shell builtin
|
| 121 |
: is a special shell builtin
|
| 122 |
true is a shell builtin
|
| 123 |
|
| 124 |
export is a special shell builtin
|
| 125 |
## END
|
| 126 |
|
| 127 |
## N-I bash STDOUT:
|
| 128 |
cd is a shell builtin
|
| 129 |
eval is a shell builtin
|
| 130 |
: is a shell builtin
|
| 131 |
true is a shell builtin
|
| 132 |
|
| 133 |
export is a shell builtin
|
| 134 |
## END
|
| 135 |
|
| 136 |
## N-I zsh STDOUT:
|
| 137 |
cd is a shell builtin
|
| 138 |
eval is a shell builtin
|
| 139 |
: is a shell builtin
|
| 140 |
true is a shell builtin
|
| 141 |
|
| 142 |
export is a reserved word
|
| 143 |
## END
|
| 144 |
|
| 145 |
|
| 146 |
case $SH in bash|zsh|dash) exit ;; esac
|
| 147 |
|
| 148 |
type .
|
| 149 |
type source
|
| 150 |
|
| 151 |
# no agreement here!
|
| 152 |
# type local
|
| 153 |
# type typeset
|
| 154 |
|
| 155 |
## STDOUT:
|
| 156 |
. is a special shell builtin
|
| 157 |
source is a shell builtin
|
| 158 |
## END
|
| 159 |
|
| 160 |
## BUG ash STDOUT:
|
| 161 |
. is a special shell builtin
|
| 162 |
source is a special shell builtin
|
| 163 |
## END
|
| 164 |
|
| 165 |
## N-I bash/zsh/dash STDOUT:
|
| 166 |
## END
|