📄 notes
字号:
Illegal instruction (core dumped) - (all) $ for i in a b c ; do echo $i, ${i[2]}, ${i[10]} ; done a, , a, , b a, , c $ - (all) $ echo ${abc:-G { I } K } G { I K } $ $ abc=hi $ echo ${abc:-G { I } K } hi K } $ The second echo should only have printed `hi'. - (all) $ echo ${abc:- > foo} syntax error: > unexpected $ - (all? hpux) read reads too much from pipe (when pipe isn't stdin) print 'hi\nthere' | ksh 8<&0 0< /dev/tty $ read -u8 x $ print $x hi $ cat 0<&8 $ read -u8 y $ print $y there $ - (all) $ umask 0 $ umask 00 $ - (osf, mips, !hpux) $ exec alias alias: not found (shell dead) - (all) non-white space IFS in non-substitution not preserved $ IFS="$IFS:" $ echo : "$@" # this is ok : $ echo :"$@" # this should print : too (me thinks) $ - (only osf/1) $ set +m $ sleep 1 & # wait for a sec or two $ jobs Memory fault (core dumped) - (all) $ (sleep 1 & echo hi) & [1] 123 $ [1] 234 hi - (osf/1, mips) $ getopts abc optc -a -b -c $ getopts abc optc -a -b -c $ getopts abc optc -a Memory fault (core dumped) - (osf/1) POSIX says OPTIND shall be initialized to 1 $ echo $OPTIND 0 $ - (osf/1 + others?) $ typeset -ri r=10 $ let r=12 $ echo $r 12 $ - (osf/1 + others?) $ typeset -i a $ typeset -L3 a Memory fault (core dumped) - (osf/1 + others?): -L strips leading \ \t\n\r, -R only strips trailing spaces $ typeset -L3 x $ x=' ^I^J^M 2' $ echo "($x)" (2 ) $ typeset -R3 y $ x='2^I^J^M ' $ echo "($x)" (^I^J^M) $ - (osf/1 + others?) $ typeset +i RANDOM Memory fault (core dumped) - (osf/1 + others?): -L/-R/-Z clear -l/-u after assignment and vise versa $ typeset -u x=ab $ echo "($x)" (AB) $ typeset -L4 x=def $ echo "($x)" (DEF ) $ typeset | grep ' x$' leftjust 4 x $ $ typeset -L4 x=def $ echo "($x)" (def ) $ typeset -u x=ab $ echo "($x)" (AB ) $ typeset | grep ' x$' uppercase x $ $ typeset -i x $ x='2()' $ x='()' $ x='2(4)' - (osf/1, others?) $ unset foo $ echo "${foo:-"*"}" <results of * expansion> $ - (osf/1, others?) $ alias blah blah: alias not found $ alias -x blah | grep blah blah $ type blah Memory fault (core dumped) - (osf/1, others?) $ trap 'echo hi; false' ERR $ false hi hi .... Memory fault (core dumped) - (osf/1, others?) $ typeset +i ERRNO Memory fault (core dumped) - (osf/1, others?) $ X=abcdef $ echo ${X#a{b,c}e} # does not match {} inside word part of ${..#..} abcdefe} $ - (osf/1, others?) $ x=f=abcdef $ echo ${f#a|abc} def $ echo ${f#abc|a} bcdef $ echo ${f#abc|a|d} abcdef $ - (osf/1, hp-ux, others?) $ i() echo hi $ typeset -f function i { hi $ - (osf/1, others?) $ function X { echo start of X function Y { echo in Y } echo end of X } $ X start of X end of X $ typeset -f function X { echo start of X function Y { echo in Y } echo end of X } function Y { echo in Y echo end of X } } $ - (osf/1, others?) $ while read x; do print -r "A $x"; done |& [1] 18212 $ exec 8<&p $ kill %1 Memory fault - (osf/1, others?) Error only happens for builtin commands (/bin/echo works) $ while read x; do print -r "A $x"; done |& [1] 18212 $ echo hi <&p hi $ echo hi <&p ksh: p: bad file unit number $ while read x; do print -r "A $x"; done |& ksh: process already exists $ - (osf/1, others?) in restricted shells, command -p should not work. $ PATH=/tmp ksh -r $ print hi | command -p cat -n 1 hi $ - (osf/1, others?) error message wrong for autoload files that don't define functions $ FPATH=/tmp $ echo echo hi there > /tmp/aja $ aja hi there ksh: echo: not found $ - (SunOS M-12/28/93d): $ cat -n << X $( > echo foo > ) > X > echo bar ) ./ksh93: X: cannot open [No such file or directory] Memory fault (core dumped)POSIX sh questions (references are to POSIX 1003.2-1992) - arithmetic expressions: how are empty expressions treated? (eg, echo $(( ))). at&t ksh (and now pdksh) echo 0. Same question goes for `test "" -eq 0' - does this generate an error or, if not, what is the exit code? - should tilde expansion occur after :'s in the word part of ${..=..}? (me thinks it should) - if a signal is received during the execution of a built-in, does the builtin command exit or the whole shell? - is it legal to execute last command of pipeline in current execution environment (eg, can "echo foo | read bar" set bar?) - what action should be taken if there is an error doing a dup due to system limits (eg, not enough feil destriptors): is this a "redirection error" (in which case a script will exit iff the error occured while executing a special built-in)? IMHO, shell should exit script. Couldn't find a blanket statement like "if shell encounters an unexpected system error, it shall exit non-interactive scripts"...POSIX sh bugs (references are to POSIX 1003.2-1992) - in vi insert mode, ^W deletes to beginning of line or to the first blank/punct character (para at line 9124, section 3). This means "foo ^W" will do nothing. This is inconsistent with the vi spec, which says delete preceding word including and interceding blanks (para at line 5189, section 5). - parameter expansion, section 3.6.2, line 391: `in each case that a value of word is needed (..), word shall be subjected to tilde expansion, parameter expansion, ...'. Various expansions should not be performed if parameter is in double quotes. - the getopts description says assigning OPTIND a value other than 1 produces undefined results, while the rationale for getopts suggests saving/restoring the OPTIND value inside functions (since POSIX functions don't do the save/restore automatically). Restoring OPTIND is kind of dumb since getopts may have been in the middle of parsing a group of flags (eg, -abc). - unclear whether arithmetic expressions (eg, $((..))) should understand C integer constants (ie, 0x123, 0177). at&t ksh doesn't and neither does pdksh. - `...` definition (3.6.3) says nothing about backslash followed by a newline, which sh and at&t ksh strip out completely. e.g., $ show-args `echo 'X Y'` Number of args: 1 1: <XY> $ POSIX would indicate the backslash-newline would be preserved. - does not say how "cat << ''" is to be treated (illegal, read 'til blank line, or read 'til eof). at&t ksh reads til eof, bourne shell reads 'til blank line. pdksh reads 'til blank line.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -