Re: Bourne shell "if" syntax

2013-06-11 Thread Teske, Devin
On Jun 11, 2013, at 2:56 AM, Jan Henrik Sylvester wrote: > On 06/10/2013 21:10, dte...@freebsd.org wrote: >> Character sentinels are not required. >> >> FreeBSD's sh(1) knows (because "[" is a built-in) that when you quote a >> parameter, that it is not (even if the value begins with "-") not an

Re: Bourne shell "if" syntax

2013-06-11 Thread Jan Henrik Sylvester
On 06/10/2013 21:10, dte...@freebsd.org wrote: > Character sentinels are not required. > > FreeBSD's sh(1) knows (because "[" is a built-in) that when you quote a > parameter, that it is not (even if the value begins with "-") not an operator. What you are saying here is at least misleading. I ju

Re: Bourne shell "if" syntax

2013-06-11 Thread Christoph Kukulies
On 10.06.2013 20:53, lcon...@go2france.com wrote: script fragment: PTR=`dig @some.dns +short +norec -x a.b.c.d` echo "$PTR" if [ "$PTR" == "" ] ; then Use something like (== is wrong, btw.) #!/bin/sh if [ "X$1" = "X" ] ; then echo foo fi -- Christoph echo "$PTR" >> /path/

RE: Bourne shell "if" syntax

2013-06-10 Thread dteske
> -Original Message- > From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- > questi...@freebsd.org] On Behalf Of jb > Sent: Monday, June 10, 2013 12:53 PM > To: freebsd-questions@freebsd.org > Subject: Re: Bourne shell "if" syntax > > Mich

Re: Bourne shell "if" syntax

2013-06-10 Thread jb
Michael Sierchio tenebras.com> writes: > ... > Right. Many scripts seem to assume that sh is bash, and that's > certainly not the case here. > > if [ "x$BLAH" = "x" ]; then > > is the most reliable and portable way of determining if it's a string > of zero length. Actually this trick is not

Re: Bourne shell "if" syntax

2013-06-10 Thread Tim Daneliuk
On 06/10/2013 02:21 PM, dte...@freebsd.org wrote: ctually, there's another reason you should also avoid the above (unquoted parameter), and that's in the case of a multi-word value. For example: Yup, that's the compelling case for using quoting. -- -

RE: Bourne shell "if" syntax

2013-06-10 Thread dteske
> -Original Message- > From: Devin Teske [mailto:devin.te...@fisglobal.com] On Behalf Of > dte...@freebsd.org > Sent: Monday, June 10, 2013 12:19 PM > To: tun...@tundraware.com; freebsd-questions@freebsd.org > Cc: dte...@freebsd.org > Subject: RE: Bou

Re: Bourne shell "if" syntax

2013-06-10 Thread Michael Sierchio
On Mon, Jun 10, 2013 at 12:16 PM, Tim Daneliuk wrote: > That wasn't really my point. I use sentinels because in the face of an > empty string this: > >if [ $PTR = "" ] > > Actually evaluates to: > >if [ = "" ] > > Which throws an error. Right. Many scripts seem to assume that sh is bas

RE: Bourne shell "if" syntax

2013-06-10 Thread dteske
> -Original Message- > From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- > questi...@freebsd.org] On Behalf Of Tim Daneliuk > Sent: Monday, June 10, 2013 12:17 PM > To: dte...@freebsd.org > Cc: freebsd-questions@freebsd.org > Subject: Re: Bourne shel

Re: Bourne shell "if" syntax

2013-06-10 Thread Tim Daneliuk
On 06/10/2013 02:10 PM, dte...@freebsd.org wrote: -Original Message- From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- questi...@freebsd.org] On Behalf Of Tim Daneliuk Sent: Monday, June 10, 2013 12:06 PM To: freebsd-questions@freebsd.org Subject: Re: Bourne shell &qu

RE: Bourne shell "if" syntax

2013-06-10 Thread dteske
> -Original Message- > From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- > questi...@freebsd.org] On Behalf Of Tim Daneliuk > Sent: Monday, June 10, 2013 12:06 PM > To: freebsd-questions@freebsd.org > Subject: Re: Bourne shell "if" syntax >

Re: Bourne shell "if" syntax

2013-06-10 Thread Mark Felder
On Mon, 10 Jun 2013 14:05:45 -0500, Tim Daneliuk wrote: if [ _"$PTR" == _ ] ; then I've never seen this syntax before. Intriguing! ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions

Re: Bourne shell "if" syntax

2013-06-10 Thread Tim Daneliuk
On 06/10/2013 01:59 PM, dte...@freebsd.org wrote: -Original Message- From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- questi...@freebsd.org] On Behalf Of lcon...@go2france.com Sent: Monday, June 10, 2013 11:53 AM To: freebsd-questions@freebsd.org Subject: Bourne shell "

Re: Bourne shell "if" syntax

2013-06-10 Thread Tim Daneliuk
On 06/10/2013 01:53 PM, lcon...@go2france.com wrote: script fragment: PTR=`dig @some.dns +short +norec -x a.b.c.d` echo "$PTR" if [ "$PTR" == "" ] ; then echo "$PTR" >> /path/to/PTR_absent.txt fi === output for an IP: a-b-c-d.domain.net. [: a-b-c-d.domain.net.: unexpecte

RE: Bourne shell "if" syntax

2013-06-10 Thread dteske
> -Original Message- > From: Devin Teske [mailto:devin.te...@fisglobal.com] On Behalf Of > dte...@freebsd.org > Sent: Monday, June 10, 2013 11:59 AM > To: lcon...@go2france.com; freebsd-questions@freebsd.org > Cc: Devin Teske > Subject: RE: Bou

RE: Bourne shell "if" syntax

2013-06-10 Thread dteske
> -Original Message- > From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- > questi...@freebsd.org] On Behalf Of lcon...@go2france.com > Sent: Monday, June 10, 2013 11:53 AM > To: freebsd-questions@freebsd.org > Subject: Bourne shell "if" syntax > > > > script fragment: >