uncertainty about command "test"
Jan-Herbert Damm <[email protected]> Sun, 22 Feb 2004 11:13:41 +0100
| Newsgroups | gmane.comp.gnu.sh-utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
dear gnu-people, trying to learn programming the bash-shell (of the valhalla release by red hat linux) i have encountered many puzzling problems that eventually i could find the simple solution to. many times this was due to some detail i had overseen. but now i have a problem that i cannot explain to myself: the command "test" seems not to work as it should. i want to test an empty file "xyz" with the following syntax: test -s xyz && echo empty this doesn't work. (command not found) if i spell the same command as: [ xyz -s ] && echo empty i get the remark "[: unary operator expected" but if i type: [ xyz-s]... or [ -sxyz ]... or test -sxyz... the command seems to work. it seems unlogical to me that the blank is not wanted by the command but i could put up with that. but now: if i run the same test with a not empty file it it still found empty by the command (it exits with status 0). what gives me to think a lot that if i enquire the exit status with $? i get this remark "bash: 0: command not found". i hope you understand what i'm talking about and have the time to clear me up about what i'm doing wrong. best regards from jan-herbert damm, berlin, germany