zshrc: Move minimal-shell to its own file
authorFrank Terbeck <ft@bewatermyfriend.org>
Wed, 30 Nov 2011 11:04:30 +0000 (12:04 +0100)
committerFrank Terbeck <ft@bewatermyfriend.org>
Wed, 30 Nov 2011 11:04:30 +0000 (12:04 +0100)
Signed-off-by: Frank Terbeck <ft@bewatermyfriend.org>
doc/grmlzshrc.t2t
etc/zsh/zshrc
usr_share_grml/zsh/functions/minimal-shell [new file with mode: 0644]

index c058db9..d10e0db 100644 (file)
@@ -569,10 +569,6 @@ Returns true, if run within an utf environment, else false.
 Creates directory including parent directories, if necessary. Then changes
 current working directory to it.
 
 Creates directory including parent directories, if necessary. Then changes
 current working directory to it.
 
-: **minimal-shell()**
-Spawns a minimally set up MirBSD Korn shell. It references no files in /usr,
-so that file system can be unmounted.
-
 : **modified()**
 Lists files in current directory, which have been modified within the
 last N days. N is an integer to be passed as first and only argument.
 : **modified()**
 Lists files in current directory, which have been modified within the
 last N days. N is an integer to be passed as first and only argument.
index 80291dc..da6d10d 100644 (file)
@@ -2148,19 +2148,6 @@ deswap() {
     print 'Finished, running "swapoff -a; swapon -a" may also be useful.'
 }
 
     print 'Finished, running "swapoff -a; swapon -a" may also be useful.'
 }
 
-# spawn a minimally set up mksh - useful if you want to umount /usr/.
-minimal-shell() {
-    emulate -L zsh
-    local shell="/bin/mksh"
-
-    if [[ ! -x ${shell} ]]; then
-        printf '`%s'\'' not available, giving up.\n' ${shell} >&2
-        return 1
-    fi
-
-    exec env -i ENV="/etc/minimal-shellrc" HOME="$HOME" TERM="$TERM" ${shell}
-}
-
 # a wrapper for vim, that deals with title setting
 #   VIM_OPTIONS
 #       set this array to a set of options to vim you always want
 # a wrapper for vim, that deals with title setting
 #   VIM_OPTIONS
 #       set this array to a set of options to vim you always want
diff --git a/usr_share_grml/zsh/functions/minimal-shell b/usr_share_grml/zsh/functions/minimal-shell
new file mode 100644 (file)
index 0000000..dd72cff
--- /dev/null
@@ -0,0 +1,15 @@
+# spawn a minimally set up mksh - useful if you want to umount /usr/.
+emulate -L zsh
+
+local shell="/bin/mksh"
+local env_file="/etc/minimal-shellrc"
+
+if [[ ! -x ${shell} ]]; then
+    printf '`%s'\'' not available, giving up.\n' ${shell} >&2
+    return 1
+elif [[ ! -f ${env_file} ]]; then
+    printf 'minimal-shell: Configuration missing: `%s'\''\n' ${shell} >&2
+    return 2
+fi
+
+exec env -i ENV="$env_file" HOME="$HOME" TERM="$TERM" ${shell}