SHELL開發時常用函數

    版本為 22:25, 20 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    一些很實用的函數範例

    Pause 暫停

    用途: 可用於程式開發及偵錯

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    Error 錯誤訊息

    用途:輸出錯誤訊息

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    詢問 Yes/No

    用法: getyn "Would you like to install WANPIPE now? [y]"

    prompt()
    {
    	if test $NONINTERACTIVE; then
    		return 0
    	fi
    
    	echo -ne "$*" >&2
    	read CMD rest
    	return 0
    }
    
    getyn()
    {
    	if test $NONINTERACTIVE; then
    		return 0
    	fi
    
    	while prompt "$* (y/n) "
    	do	case $CMD in
    		[yY])	return 0
    			;;
    		[nN])	return 1
    			;;
    		*)	echo -e "\nPlease answer y or n" >&2
    			;;
    		esac
    	done
    } 
    
    Powered by MindTouch Core