bash script issue

Peter plpeter2006-/E1597aS9LQAvxtiuMwx3w at public.gmane.org
Wed Sep 3 15:19:49 UTC 2014


D. Hugh Redelmeier <hugh at ...> writes:

> I don't remember an ordinary shell context where a pathname can be
> confused with number.  Can you give an example?

Ordinary not, but:

echo $((07+1)) -> 8 (yes... why?)
echo $((007+1)) -> 8 (hmm, must be Mr. Bond)
echo $((077+1)) -> 64 (no kidding, 077oct is 64dec)
echo $((078+1)) -> bash: 078: value too great for base (error token is "078")

So if you do any math on any numbers for example numbered files like
DCIM/IMG0077.jpg you WILL likely be bitten. I think the 1st application
where I was bitten was many years ago trying to figure out missing and
duplicate IMGnnnnn.jpg files in a large recovered image directory. I also
tried to be clever and rename files such that there would be no gaps upon
finding missing files, in one pass. That did not go well, I had a 10% or so
file loss when done. There are many other 'opportunities' to get bitten.

Peter


--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list