On 2011-02-15 8:09 PM, Philip Prindeville wrote: > On 2/15/11 2:13 AM, Ferenc Wagner wrote: >> Peter Wagner<tripo...@gmx.at> writes: >> >>> - [ -n "$leasefile" ]&& [ -e "$leasefile" ] || touch "$leasefile" >>> + [ -n "$leasefile" ]&& ( [ -e "$leasefile" ] || touch "$leasefile" ) >> Looks like this is fixed already by commit 15fba44a (but see point 6 of >> http://mywiki.wooledge.org/BashPitfalls and the rest for an interesting >> read) so the following is academic, but I typed it before checking... >> >> It's cheeper to use braces in such cases to avoid subshell creation: >> >> [ -n "$leasefile" ]&& { [ -e "$leasefile" ] || touch >> "$leasefile"; } >> >> Btw. is the -e test really necessary? Why not simply >> >> [ -n "$leasefile" ]&& touch "$leasefile" >> ? > > Well, to use your own point... why create an extra process to "touch" a file > that already exists? > And if it does exist, do you necessarily want to modify the timestamp on it? https://dev.openwrt.org/changeset/25540 - committed more than 24 hours ago, rendering much of this discussion irrelevant ;)
> I don't like using "-e" because what happens if the name exists, but it's a > directory or a socket or a block file... > > Why not use "-f" instead? If it's a directory or a socket, then touch certainly won't make things better, so -e is enough, unless you also want to add a conditional rm -f, as well as some extra checks to make sure it isn't a symlink, .... nah, screw that, I don't believe in defensive programming ;) - Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel