Cool, I'll change some code to adopt some these standards on cdcontrol.
Thanks
Bill Davidsen wrote:
>
> Just a few notes on writing shell scripts in general:
>
> Filenames:
>
> bash, ksh, and recent SysV[34] shells all include $RANDOM, so a name
> like /tmp/$$_$RANDOM gives unique filenames. For the deeply paranoid who
> might have old files around, you can:
> MyFile=/tmp/$$_$RANDOM.myapp
> while [ -f $MyFile ]; do MyFile=/tmp/$$_$RANDOM.myapp; done
> while will give you a unique name. Of course it indicates other
> problems with old files hanging around, but that's not the issue.
>
> Results of command execution:
>
> Accent grave is more portable than paren notation, so `cmd` works in
> more places than $(cmd). On the other hand, $(is easier to read) if you
> know you will have a recent shell.
>
> Arithmetic:
>
> most portable is the use of expr to do math. If you accept that the
> "let" capability has been around for a decade, as has $((...)) notation,
> you can cut a few corners. If don't know if SysV shell has the $[...]
> notation supported by bash/ksh, but if total portability is my goal I
> still use expr.
>
> In order or partability:
> a=`expr $a + 4`
> a=$(($a+4))
> let a=a+4
> a=$[a+4]
>
> Functions and alias:
>
> Yes, there are still shells around which lack them. Not anything
> modern, but SysV2 shell is not as dead as it deserves to be :-(
>
> None of this is a comment on existing code, just a few tricks I picked
> up when doing support for scripts which had to run on everything from
> SysIII to BSD, including Xenix. Hopefully they will save someone some
> time.
>
> --
> -bill davidsen ([EMAIL PROTECTED])
> "The secret to procrastination is to put things off until the
> last possible moment - but no longer" -me
>
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
--
---------------------------
Gleydson Mazioli da Silva
[EMAIL PROTECTED]
[EMAIL PROTECTED]
N�o h� quem n�o cometa erros e grandes homens cometem grandes erros.
--Paulo Francis
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]