今天遇到個let not found

2022-02-07 23:23:19 字數 4185 閱讀 8271

view code

1 #!/bin/bash

2#arglist.h

3 #2012-06-14

45 e_badargs=6567

if [ ! -n "$1"

]8then

9echo

"usage: `basename $0` argument1 argument2 etc."10

exit $e_badargs

11fi

12echo

1314 index=1

15#注意

16echo

"listing args with \"\$*\":"17

for arg in"$*

" # ""

18do

19echo

"arg #$index = $arg

"20 let "

index+=1"21

done

2223

echo

"entire arg list seen as single word."24

echo

2526 index=1

2728

echo

"listing args with\"\$@\":"29

for arg in"$@

"30do31

echo

"arg #$index = $arg

"32 let "

index+=1"33

done

34echo

"arg list seen as seperate words."35

36echo

3738 index=1

39echo

"listing args with \$* (unquoted):"40

for arg in $*

41do

42echo

"arg #$index = $arg

"43 let "

index+=1"44

done

45echo

"arg list seen as separate words.

"46 exit 0

除錯的時候直接用了 

sh -x arglist.sh t1 t2 t3 t4 t5 t6 t7
結果就悲催了:

+ e_badargs=65

+ [ ! -n t1 ]

+ echo

+ index=1

+ echo listing args with "$*"

:listing args with "$*

":+ echo arg #1 =t1 t2 t3 t4 t5 t6 t7

arg #

1 =t1 t2 t3 t4 t5 t6 t7

+ let index+=1

arglist.

sh: 20: arglist.sh

: let: not found

+ echo

entire arg list seen as single word.

entire arg list seen as single word.

+ echo

+ index=1

+ echo listing args with"$@"

:listing args with"$@

":+ echo arg #1 =t1

arg #

1 =t1

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo arg #1 =t2

arg #

1 =t2

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo arg #1 =t3

arg #

1 =t3

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo arg #1 =t4

arg #

1 =t4

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo arg #1 =t5

arg #

1 =t5

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo arg #1 =t6

arg #

1 =t6

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo arg #1 =t7

arg #

1 =t7

+ let index+=1

arglist.

sh: 32: arglist.sh

: let: not found

+ echo

arg list seen as seperate words.

arg list seen as seperate words.

+ echo

+ index=1

+ echo listing args with $*(unquoted):

listing args with $*(unquoted):

+ echo arg #1 =t1

arg #

1 =t1

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo arg #1 =t2

arg #

1 =t2

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo arg #1 =t3

arg #

1 =t3

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo arg #1 =t4

arg #

1 =t4

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo arg #1 =t5

arg #

1 =t5

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo arg #1 =t6

arg #

1 =t6

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo arg #1 =t7

arg #

1 =t7

+ let index+=1

arglist.

sh: 43: arglist.sh

: let: not found

+ echo

arg list seen as separate words.

arg list seen as separate words.

+ exit 0

/bin/sh指向了dash而不是bash,dash不支援let命令。
所以改用,

bash -x arglist.sh t1 t2 t3 t4 t5 t6 t7
結果就ok了,若非是用sh -x,還遇不到這個小問題,呵呵。

很水的東東,私錄一下。

今天遇到乙個亂碼問題

用ecplise自動生成的servlet,會自動帶有這麼一句話 他被放在了 request.setcharacterencoding utf 8 response.setcharacterencoding utf 8 的前面,然後 的時候 request.getrequestdispatcher i...

今天遇到的乙個算發

encode 一字串 如果字元小於0則直接拷貝 如果是數字則拷貝當前數字加乙個後繼字串 如果是其他字母等直接拷貝 如果是 下劃線則轉換成 ul decode 解碼 encode 部分 strold this.textbox1.text strleng strold.length char a str...

今天遇到乙個奇怪的問題

想實現乙個使用者訪問頁面,得到使用者的外網位址 在公司上。程式是沒問題。正常獲取使用者的位址 測試 哪位遇到這樣的問題過。如下 string ip request.getheader x forwarded for if ip null ip.length 0 unknown equalsignor...