Article View: gnu.bash.bug
Article #429Bad bash bug regarding if statements
From: kayvan
Date: Fri, 04 Aug 1989 20:51
Date: Fri, 04 Aug 1989 20:51
37 lines
1382 bytes
1382 bytes
The following obviously wrong shell script:
------------------------------ begin
#!/bin/bash
if Your_Mother_Wears_Army_Boots
then
How about we go out tonight?
No way, Jose!
NO_ENDING_FI
------------------------------ end
Is silently ignored. The status upon return in 0.
I found this bug in the following subtle case:
------------------------------ begin
#!/bin/bash - Test shell script
if [ "$LOGNAME" != "" ]
then
export USER=$LOGNAME ; echo USER set to LOGNAME
else
export USER=`who am i | awk '{print $1}'`
echo USER set to who output. $USER
endif
echo "Rest of script follows."
echo "Hello????"
------------------------------ end
The script *looked* okay, but all variables after this section that depended
on USER were not being set.
The problem was, of course, the endif.
---Kayvan
Kayvan Sylvan @ Transact Software, Inc. -*- Mountain View, CA (415) 961-6112
Internet: kayvan@Transact.COM -*- UUCP: ...!{apple,pyramid,mips}!mrspoc!kayvan
Technical Details
Message-ID:
<8908042051.AA02207@apple.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!mrspoc.transact.com!kayvanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!mrspoc.transact.com!kayvan From: kayvan@mrspoc.transact.com Newsgroups: gnu.bash.bug Subject: Bad bash bug regarding if statements Message-ID: <8908042051.AA02207@apple.com> Date: 4 Aug 89 20:51:55 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 37