Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #186219
| From | Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Weird shell script behavior in a cron job |
| Date | 2017-08-31 08:10 +0200 |
| Message-ID | <ukqPT-1WF-3@gated-at.bofh.it> (permalink) |
| References | <ukfB9-3fk-39@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
James H. H. Lampert: > Could it be that |cron| is running it an entirely different shell, > that doesn't understand the |if| statement? > Despite what others have said, the answer to this question is no. Whilst you /are/ running two different shells, the problem is not the |if| statement. Both of those shells understand that |if| statement. The difference between the shells involves the fact that you have assumed a particular exit status for the |cd| command for non-existent directories. That's the exit status that the |cd| command results in, in one of your shells. But it is not the exit status that results in the other. Ironically, you are using the |[| command /anyway/, and that command has a direct method, its |-d| operator, for testing for the non-existence of a directory. So you are going around the houses a bit in order to achieve what you could be achieving directly, and portably (without assumptions about exit statuses), with the |[| command itself.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Weird shell script behavior in a cron job "James H. H. Lampert" <jamesl@touchtonecorp.com> - 2017-08-30 20:10 +0200
Re: Weird shell script behavior in a cron job "James H. H. Lampert" <jamesl@touchtonecorp.com> - 2017-08-30 20:40 +0200
Re: Weird shell script behavior in a cron job David Margerison <deltam@electrosonics.com.au> - 2017-09-01 16:50 +0200
Re: Weird shell script behavior in a cron job Reco <recoverym4n@gmail.com> - 2017-08-30 20:40 +0200
Re: Weird shell script behavior in a cron job Greg Wooledge <wooledg@eeg.ccf.org> - 2017-08-30 20:50 +0200
Re: Weird shell script behavior in a cron job David Wright <deblis@lionunicorn.co.uk> - 2017-08-30 20:50 +0200
Re: Weird shell script behavior in a cron job Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM> - 2017-08-31 08:10 +0200
Re: Weird shell script behavior in a cron job Greg Wooledge <wooledg@eeg.ccf.org> - 2017-08-31 14:10 +0200
Re: Weird shell script behavior in a cron job Reco <recoverym4n@gmail.com> - 2017-08-31 14:20 +0200
Re: Weird shell script behavior in a cron job "James H. H. Lampert" <jamesl@touchtonecorp.com> - 2017-08-31 17:40 +0200
csiph-web