4918
5880
3万
GROAD
曲径通幽,安觅芳踪。
[beyes@localhost ~]$ echo $PS4 +
#!/bin/bash checkname() { if [ "$USER" = "beyes" ];then return 0 else return 1 fi } checkuid() { if ["$UID" -eq 500 ]; then return 0 else return 1 fi } checkname if [ "$?" -eq 0 ]; then echo "check name ok!" else echo "check name failed" fi checkuid if [ "$?" -eq 0 ]; then echo "check uid ok!" exit 0 else echo "check uid failed" exit 1 fi
[beyes@localhost ~]$ sh sp4.sh sp4.sh: line 7: syntax error near unexpected token `else' sp4.sh: line 7: ` else'
[beyes@localhost ~]$ sh sp4.sh check name ok! sp4.sh: line 14: [500: command not found check uid failed
[beyes@localhost ~]$ export PS4='+$LINENO: {${FUNCNAME[0]}} '
[beyes@localhost ~]$ sh sp4.sh check name ok! sp4.sh: line 14: [500: command not found check uid failed [beyes@localhost ~]$ sh -x sp4.sh +21: {} checkname +5: {checkname} '[' beyes = beyes ']' +6: {checkname} return 0 +22: {} '[' 0 -eq 0 ']' +23: {} echo 'check name ok!' check name ok! +28: {} checkuid +14: {checkuid} '[500' -eq 500 ']' sp4.sh: line 14: [500: command not found +17: {checkuid} return 1 +29: {} '[' 1 -eq 0 ']' +33: {} echo 'check uid failed' check uid failed +34: {} exit 1
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )
GMT+8, 2025-5-4 13:10 , Processed in 0.084355 second(s), 23 queries .
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.