[Gllug] Shell scripts

tet at accucard.com tet at accucard.com
Fri May 3 14:56:21 UTC 2002


>mv in the same directory will thunk straight down to rename(2), which is
>guaranteed atomic by POSIX.
>
>(But you knew that already.)

Yes, I did. I should have mentioned that it was only atomic for moves on
the same filesystem. But even then, I seem to recall one of the SCO/Veritas
people (Mark?) claiming that that didn't always hold for certain rare
cases. How true is it for NFS, for example? Presumably, the underlying
filesystem move will still be atomic, but will NFS clients still see an
atomic move?

>> Note that this method of iterating throught the files doesn't handle
>> filenames containing whitespace, but is otherwise fairly reasonable.
>
>You can mess with the IFS variable to handle that too (at least to some
>extent).

Yes, but you still have to pick an alternative character, the presence
of which in a filename would equally cause it to fail. AFAIK, the only
two characters guaranteed to never exist in a filename are / and NUL.
We can't use / for obvious reasons, and I don't think the shell handles
NUL characters very well...

>> Also note the use of lower case variable names. By convention, upper
>> case is reserved for environment variables. Shell variables should be
>> lower case.
>
>Hm. I've never stuck to that; maybe I should...

Like I said, it's just convention. But conventions make for clarity
and consistency, and for that reason alone should generally be stuck
to unless there's good reason not to do otherwise.

Tet

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list