zshrc: actively do: "setopt unset"
authorFrank Terbeck <ft@bewatermyfriend.org>
Sun, 11 Oct 2009 23:10:30 +0000 (01:10 +0200)
committerFrank Terbeck <ft@bewatermyfriend.org>
Sun, 11 Oct 2009 23:30:07 +0000 (01:30 +0200)
It seems like some people think it is a good idea to unset that option.
That is a very bad idea though.

Why? Well, because of this:
% unset foo
% echo "foo$foo"
zsh: foo: parameter not set

That is totally incompatible with every other bourne like shell out
there. And it breaks many shell idioms.

In fact, it will break at least 'vcs_info()' and 'accept_line()' for us.
Which is unacceptable.

I also added 'emulate -L zsh' to accept-line() and vcs_info(), which are
two functions, that will fail horribly with 'unset' unset. That will
leave the shell intact even if someone wants to 'setopt no_unset' in
his/her .zshrc.local

debian/changelog
etc/zsh/zshrc

index c8e2dd3..196e937 100644 (file)
@@ -3,8 +3,9 @@ grml-etc-core (0.3.76) UNRELEASED; urgency=low
   * zshrc: add openssl hash functions [Closes: issue741]
   * zshrc: use history-incremental-pattern-search-* for incremental history
     searches per default (via ^r and ^s).
+  * zshrc: actively do 'setopt unset'
 
- -- Frank Terbeck <ft@grml.org>  Thu, 08 Oct 2009 11:29:38 +0200
+ -- Frank Terbeck <ft@grml.org>  Mon, 12 Oct 2009 01:10:02 +0200
 
 grml-etc-core (0.3.75) unstable; urgency=low
 
index 43e77a1..2cff02b 100644 (file)
@@ -281,6 +281,7 @@ setopt nobeep               # avoid "beep"ing
 setopt pushd_ignore_dups    # don't push the same dir twice.
 setopt noglobdots           # * shouldn't match dotfiles. ever.
 setopt noshwordsplit        # use zsh style word splitting
+setopt unset                # don't error out when unset parameters are used
 
 # }}}
 
@@ -649,7 +650,7 @@ fi
 zstyle ':acceptline:*' rehash true
 
 function Accept-Line() {
-    setopt localoptions noksharrays
+    emulate -L zsh
     local -a subs
     local -xi aldone
     local sub
@@ -668,6 +669,7 @@ function Accept-Line() {
 }
 
 function Accept-Line-getdefault() {
+    emulate -L zsh
     local default_action
 
     zstyle -s ":acceptline:${alcontext}" default_action default_action
@@ -682,7 +684,7 @@ function Accept-Line-getdefault() {
 }
 
 function accept-line() {
-    setopt localoptions noksharrays
+    emulate -L zsh
     local -a cmdline
     local -x alcontext
     local buf com fname format msg default_action
@@ -1850,6 +1852,7 @@ vcs_info_printsys () { # {{{
 }
 # }}}
 vcs_info_lastmsg () { # {{{
+    emulate -L zsh
     local -i i
 
     VCS_INFO_maxexports
@@ -1865,6 +1868,8 @@ vcs_info_lastmsg () { # {{{
 }
 # }}}
 vcs_info () { # {{{
+    emulate -L zsh
+    setopt extendedglob
     local pat
     local -i found
     local -a VCSs disabled dps