diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Doc/Zsh/mod_attr.yo | 10 | ||||
-rw-r--r-- | Doc/Zsh/options.yo | 13 | ||||
-rw-r--r-- | Src/options.c | 1 | ||||
-rw-r--r-- | Src/signals.c | 10 | ||||
-rw-r--r-- | Src/zsh.h | 1 | ||||
-rw-r--r-- | Test/C03traps.ztst | 17 |
7 files changed, 50 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index 49a2eb69a..1718fc445 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-09-12 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * Mikael: 28253: Doc/Zsh/mod_attr.yo: document -h argument to + attribute commands. + 2010-09-08 Peter Stephenson <pws@csr.com> * unposted: Functions/Zle/replace-string-again: safety on @@ -13618,5 +13623,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5074 $ +* $Revision: 1.5075 $ ***************************************************** diff --git a/Doc/Zsh/mod_attr.yo b/Doc/Zsh/mod_attr.yo index 96ac2e011..566e67f2b 100644 --- a/Doc/Zsh/mod_attr.yo +++ b/Doc/Zsh/mod_attr.yo @@ -2,31 +2,33 @@ COMMENT(!MOD!zsh/attr Builtins for manipulating extended attributes (xattr). !MOD!) The tt(zsh/attr) module is used for manipulating extended attributes. +The tt(-h) option causes all commands to operate on symbolic links instead +of their targets. The builtins in this module are: startitem() findex(zgetattr) cindex(extended attributes, xattr, getting from files) -item(tt(zgetattr) var(filename) var(attribute) [ var(parameter) ])( +item(tt(zgetattr) [ tt(-h) ] var(filename) var(attribute) [ var(parameter) ])( Get the extended attribute var(attribute) from the specified var(filename). If the optional argument var(parameter) is given, the attribute is set on that parameter instead of being printed to stdout. ) findex(zsetattr) cindex(extended attributes, xattr, setting on files) -item(tt(zsetattr) var(filename) var(attribute) var(value))( +item(tt(zsetattr) [ tt(-h) ] var(filename) var(attribute) var(value))( Set the extended attribute var(attribute) on the specified var(filename) to var(value). ) findex(zdelattr) cindex(extended attributes, xattr, removing, deleting) -item(tt(zdelattr) var(filename) var(attribute))( +item(tt(zdelattr) [ tt(-h) ] var(filename) var(attribute))( Remove the extended attribute var(attribute) from the specified var(filename). ) findex(zlistattr) cindex(extended attributes, xattr, listing) -item(tt(zlistattr) var(filename) [ var(parameter) ])( +item(tt(zlistattr) [ tt(-h) ] var(filename) [ var(parameter) ])( List the extended attributes currently set on the specified var(filename). If the optional argument var(parameter) is given, the list of attributes is set on that parameter instead of being printed to stdout. diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index a86fbe68e..342df4680 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -1876,6 +1876,19 @@ If multibyte character support is not compiled into the shell this option is ignored; all octets with the top bit set may be used in identifiers. This is non-standard but is the traditional zsh behaviour. ) +pindex(POSIX_TRAPS) +pindex(NO_POSIX_TRAPS) +pindex(POSIXTRAPS) +pindex(NOPOSIXTRAPS) +cindex(traps, on function exit) +cindex(traps, POSIX compatibility) +item(tt(POSIX_TRAPS) <K> <S>)( +When the is option is set, the usual zsh behaviour of executing +traps for tt(EXIT) on exit from shell functions is suppressed. +In that case, manipulating tt(EXIT) traps always alters the global +trap for exiting the shell; the tt(LOCAL_TRAPS) option is +ignored for the tt(EXIT) trap. +) pindex(SH_FILE_EXPANSION) pindex(NO_SH_FILE_EXPANSION) pindex(SHFILEEXPANSION) diff --git a/Src/options.c b/Src/options.c index dedbf0c73..02b471925 100644 --- a/Src/options.c +++ b/Src/options.c @@ -204,6 +204,7 @@ static struct optname optns[] = { {{NULL, "posixcd", OPT_EMULATE|OPT_BOURNE}, POSIXCD}, {{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS}, {{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS}, +{{NULL, "posixtraps", OPT_EMULATE|OPT_BOURNE}, POSIXTRAPS}, {{NULL, "printeightbit", 0}, PRINTEIGHTBIT}, {{NULL, "printexitvalue", 0}, PRINTEXITVALUE}, {{NULL, "privileged", OPT_SPECIAL}, PRIVILEGED}, diff --git a/Src/signals.c b/Src/signals.c index 49e5e6379..d107b46d1 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -864,7 +864,8 @@ removetrap(int sig) * one, to aid in removing this one. However, if there's * already one at the current locallevel we just overwrite it. */ - if (!dontsavetrap && (isset(LOCALTRAPS) || sig == SIGEXIT) && + if (!dontsavetrap && + (sig == SIGEXIT ? !isset(POSIXTRAPS) : isset(LOCALTRAPS)) && locallevel && (!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT))) dosavetrap(sig, locallevel); @@ -932,7 +933,7 @@ starttrapscope(void) * so give it the next higher one. dosavetrap() is called * automatically where necessary. */ - if (sigtrapped[SIGEXIT]) { + if (sigtrapped[SIGEXIT] && !isset(POSIXTRAPS)) { locallevel++; unsettrap(SIGEXIT); locallevel--; @@ -960,7 +961,7 @@ endtrapscope(void) */ if (intrap) exittr = 0; - else if ((exittr = sigtrapped[SIGEXIT])) { + else if (!isset(POSIXTRAPS) && (exittr = sigtrapped[SIGEXIT])) { if (exittr & ZSIG_FUNC) { exitfn = removehashnode(shfunctab, "TRAPEXIT"); } else { @@ -1005,7 +1006,8 @@ endtrapscope(void) } if (exittr) { - dotrapargs(SIGEXIT, &exittr, exitfn); + if (!isset(POSIXTRAPS)) + dotrapargs(SIGEXIT, &exittr, exitfn); if (exittr & ZSIG_FUNC) shfunctab->freenode((HashNode)exitfn); else diff --git a/Src/zsh.h b/Src/zsh.h index 77281aa75..a825a6bab 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1987,6 +1987,7 @@ enum { POSIXCD, POSIXIDENTIFIERS, POSIXJOBS, + POSIXTRAPS, PRINTEIGHTBIT, PRINTEXITVALUE, PRIVILEGED, diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 1c4006cc4..321f5e956 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -371,6 +371,23 @@ 0: EXIT trap set in command substitution >command substitution exited + (cd ..; $ZTST_exe -fc 'setopt posixtraps; + TRAPEXIT() { print Exited; } + fn1() { trap; } + setopt localtraps # should be ignored by EXIT + fn2() { TRAPEXIT() { print No, really exited; } } + fn1 + fn2 + fn1') +0:POSIX_TRAPS option +>TRAPEXIT () { +> print Exited +>} +>TRAPEXIT () { +> print No, really exited +>} +>No, really exited + %clean rm -f TRAPEXIT |