reexec.sh
来自「一个很好的SHELL的示例。可以对学习和深入学习SHELL的朋友。一点帮助。资料」· Shell 代码 · 共 43 行
SH
43 行
#! /bin/sh# Zsh is not Bourne compatible without the following:if test -n "$ZSH_VERSION"; then emulate sh NULLCMD=:fi# Bash is not POSIX compliant without the following:test -n "$BASH_VERSION" && set -o posixSHELL="${SHELL-/bin/sh}"if test x"$1" = x--re-executed; then # Functional shell was found. Remove option and continue shiftelif "$SHELL" -c 'foo () { exit 0; }; foo' 2>/dev/null; then # The current shell works already! :else # Try alternative shells that (sometimes) support functions for cmd in sh bash ash bsh ksh zsh sh5; do set `IFS=:; X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb"; echo $X` for dir shell="$dir/$cmd" if (test -f "$shell" || test -f "$shell.exe") && "$shell" -c 'foo () { exit 0; }; foo' 2>/dev/null then # Re-execute with discovered functional shell SHELL="$shell" exec "$shell" "$0" --re-executed ${1+"$@"} fi done done echo "Unable to locate a shell interpreter with function support" >&2 exit 1fifoo () { echo "$SHELL: ta da!"}fooexit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?