[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread casper....@sun.com
> >On Thu, 07 Jun 2007 17:37:31 +0100 Alan Burlison wrote: >> Glenn Fowler wrote: > >> >> [ x$install = xyes ] && ... That only works if install is one word or none. Casper

[shell-discuss] Re: [osol-code] Re: Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re:

2007-06-07 Thread I. Szczesniak
On 6/7/07, Peter Memishian wrote: > > > Looks like it was part of UNIX2003/SUSv3 compliance in Solaris 10: > > http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4763915 > > > > In which case, -p would still be needed for any scripts that could ever be > run > > on pre-S10 releases.

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread David Korn
Here are my comments about coding error checking, the -p option, and coding style in response to all of the e-mails. There is no reason to use shcomp for checking for errors, since you can run ksh -n which will give the same warnings. ksh -n does a lot more checking and warns about obsolete or s

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Alan Burlison
Glenn Fowler wrote: [ x$install = xyes ] && ... >>> >>> or use the ksh93 [[ ... ]] >>> >>> [[ $install == yes ]] && ... > >> Or even > >> [[ ${install:-no} == yes ]] > > why complicate $install to ${install:-no} ? Just because ;-) Actually, because it will still work correctl

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Alan Burlison
Glenn Fowler wrote: >> [ x$install = xyes ] && ... > > > or use the ksh93 [[ ... ]] > > [[ $install == yes ]] && ... > > -- Glenn Fowler -- AT&T Research, Florham Park NJ -- Or even [[ ${install:-no} == yes ]] -- Alan Burlison --

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Charles Seeger
+-- Casper.Dik at sun.com wrote (Thu, 07-Jun-20,07 20:05 +0200): | | >On Thu, 07 Jun 2007 17:37:31 +0100 Alan Burlison wrote: | >> Glenn Fowler wrote: | > | >> >> [ x$install = xyes ] && ... | | That only works if install is one word or none. Which is why [ "x${install:-}" =

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread michelle olson
Hi Roland, you wrote: ... CC:'ing Michelle Olson: Michelle... is there any preferred layout/style or something which I could as "template" for the language being used ? Thanks for taking this on, sounds like a very useful new document. I think the best template is chapter 7 of the Developer's R

Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re:[shell-discuss] Re: [osol-code] Coding (style) guidelines forshellscripts ?

2007-06-07 Thread Dan Mick
Roland Mainz wrote: > Peter Memishian wrote: >> > ... but I am only getting the output of the 2nd script here... am I >> > doing something wrong ? >> >> Hmm, I don't think so, but I also recall running afoul of environment >> issues when -p was left out scripts like nightly. But now I can't >> r

[shell-discuss] Re: [osol-code] Re: Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re:

2007-06-07 Thread James Carlson
Alan Coopersmith writes: > I. Szczesniak wrote: > > Why recommend a switch which is no longer needed in Solaris >= 10 for > > /bin/ksh and /bin/ksh93? > > Because it does no harm there, and prevents massive harm on older releases, > which we know millions of people are still using. Also because t

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Glenn Fowler
On Thu, 07 Jun 2007 17:37:31 +0100 Alan Burlison wrote: > Glenn Fowler wrote: > >>[ x$install = xyes ] && ... > > > > > > or use the ksh93 [[ ... ]] > > > > [[ $install == yes ]] && ... > Or even > [[ ${install:-no} == yes ]] why complicate $install to ${install:-no} ?

[shell-discuss] Re: [osol-code] Re: Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re:

2007-06-07 Thread Peter Memishian
> > Indeed. So coming back around to Roland's write-up: I think it should > > recommend -p. > > Why recommend a switch which is no longer needed in Solaris >= 10 for > /bin/ksh and /bin/ksh93? As I understood it, the guide was not about writing shell scripts on Solaris 10+, it was about wr

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Glenn Fowler
On Thu, 7 Jun 2007 11:47:17 -0400 seeger at cise.ufl.edu (Charles Seeger) wrote: > The other classic problem is that the variable may begin with a "-", > which test will attempt to interpret as a command line switch. That > can be addressed either by putting the variable expansion on the right >

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Charles Seeger
NB: Individual addresses removed, opensolaris-code preserved. NB2: Eventually I may comment further elsewhere, as I'm not sure that these are the appropriate venues for a coding style thread. +-- Roland Mainz wrote (Thu, 07-Jun-2007, 09:47 +0200): | Casper.Dik at Sun.COM wrote: | > > | >

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Roland Mainz
Casper.Dik at Sun.COM wrote: > >On 6/6/07, Michael Shapiro wrote: > >> I'm more than happy for it to be published, just ask that you keep > >> the attribution on it so people who have questions and complaints > >> can whine at me directly. Maybe when we're done with ksh93 we > >> can have a mode

Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re:[shell-discuss] Re: [osol-code] Coding (style) guidelines forshellscripts ?

2007-06-07 Thread Roland Mainz
Peter Memishian wrote: > > > ... but I am only getting the output of the 2nd script here... am I > > doing something wrong ? > > Hmm, I don't think so, but I also recall running afoul of environment > issues when -p was left out scripts like nightly. But now I can't > reproduce the problem, so

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread casper....@sun.com
>On 6/6/07, Michael Shapiro wrote: >> I'm more than happy for it to be published, just ask that you keep >> the attribution on it so people who have questions and complaints >> can whine at me directly. Maybe when we're done with ksh93 we >> can have a mode which enforces it automatically built-

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread James Carlson
Ryan Scott writes: > Michael Shapiro wrote: > > > I'm more than happy for it to be published, just ask that you keep > > the attribution on it so people who have questions and complaints > > can whine at me directly. Maybe when we're done with ksh93 we > > can have a mode which enforces it automa

[shell-discuss] Re: [osol-code] Re: Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re:

2007-06-07 Thread Alan Coopersmith
I. Szczesniak wrote: > On 6/7/07, Peter Memishian wrote: >> >> > Looks like it was part of UNIX2003/SUSv3 compliance in Solaris 10: >> > http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4763915 >> > >> > In which case, -p would still be needed for any scripts that could >> ever be r

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread James Carlson
Roland Mainz writes: > * Be carefull with using TABS in script code, they are not portable > between editors or platforms Could you clarify this one, please? Are you referring to the ASCII TAB (0x09) character? If so, what's not "portable" about it? Are you hinting at the people who misconfigur

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Mike Gerdts
On 6/6/07, Roland Mainz wrote: > The same way as the native command works... > > > Surely ksh93 doesn't install setuid by default... > > Solaris "chown" isn't a setid application: > -- snip -- > $ ls -l /usr/bin/chown > -r-xr-xr-x 1 root bin13196 Mar 25 16:58 /usr/bin/chown > -- snip

[shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Roland Mainz
Mike Gerdts wrote: > On 6/6/07, Roland Mainz wrote: > > * Use builtin commands if the shell provides them. For example ksh93s+ > > (ksh93, version 's+') delivered with Solaris supports the following > > builtins: > > This seems to favor the use of never specifying the full path to all > of your c

Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re: [shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Roland Mainz
Peter Memishian wrote: > > > * Using -p" for starting non-interactive shell scipts is AFAIK a NO-OP, > > > e.g. > > > -- snip -- > > > #!/bin/ksh -p > > > -- snip -- > > > should be replaced with > > > -- snip -- > > > #!/bin/ksh > > > -- snip -- > > > > I've recently been burned by this

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread Roland Mainz
Danek Duvall wrote: > On Thu, Jun 07, 2007 at 12:06:34AM +0200, Roland Mainz wrote: > > Does Sun have any coding (style) guidelines/notes for Bourne/Korn/POSIX > > shell scripts ? > > No, only C (and, by some extension, C++) and Java. Shell, perl, and python > are missing. > > > A quick review o

Filename quoting... / was: Re: [shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Roland Mainz
Mike Gerdts wrote: > On 6/6/07, Michael Shapiro wrote: [snip] > One nit. In the Quoting section it says: > > Use whatever quotes are appropriate for your situation, but please > do not unnecessarily quote everything (also see 7 above). > > The numbers for the sections are missing but I

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread Roland Mainz
Ryan Scott wrote: > Michael Shapiro wrote: > > I'm more than happy for it to be published, just ask that you keep > > the attribution on it so people who have questions and complaints > > can whine at me directly. Maybe when we're done with ksh93 we > > can have a mode which enforces it automatica

[shell-discuss] Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread Roland Mainz
Danek Duvall wrote: > On Thu, Jun 07, 2007 at 12:06:34AM +0200, Roland Mainz wrote: > > Does Sun have any coding (style) guidelines/notes for Bourne/Korn/POSIX > > shell scripts ? > > No, only C (and, by some extension, C++) and Java. Shell, perl, and python > are missing. > > > A quick review o

[shell-discuss] "shcomp" vs. lint... / was: Re: [osol-code] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread Roland Mainz
Michael Shapiro wrote: > > > Roland> Does Sun have any coding (style) guidelines/notes for Bourne/Korn/ > > Roland> POSIX shell scripts ? > > > > Danek> No, only C (and, by some extension, C++) and Java. Shell, perl, and > > Danek> python are missing. > > > > James> Actually, there was a draft sh

Starting scripts with "#!/bin/ksh -p" or "#!/bin/ksh" ? / was: Re: [shell-discuss] Re: [osol-code] Coding (style) guidelines forshell scripts ?

2007-06-07 Thread Peter Memishian
> ... but I am only getting the output of the 2nd script here... am I > doing something wrong ? Hmm, I don't think so, but I also recall running afoul of environment issues when -p was left out scripts like nightly. But now I can't reproduce the problem, so maybe something's been fixed -- or m

[shell-discuss] Coding (style) guidelines for shell scripts ?

2007-06-07 Thread Roland Mainz
Hi! Does Sun have any coding (style) guidelines/notes for Bourne/Korn/POSIX shell scripts ? A quick review of some standard scripts like "bfu", "acr", some of the SMF/Dtrace shell scripts and other stuff reveals some IMO not very "nice" (where "nice" is more or less an understatement) const