zshrc: Move minimal-shell to its own file
[grml-etc-core.git] / usr_share_grml / zsh / functions / minimal-shell
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}