Does command substitution within arithmetic substitution get word split?
4
votes
2
answers
881
views
I seem to recall from comments on this site that the contents of arithmetic expansion **may** be word split, but I can't find the comment again.
Consider the following code:
printf '%d\n' "$(($(sed -n '/my regex/{=;q;}' myfile)-1))"
If the
sed
command outputs a multi-digit number and $IFS
contains digits, will the command substitution get word split before the arithmetic occurs?
(I've already tested using extra double quotes:
printf '%d\n' "$(("$(sed -n '/my regex/{=;q;}' myfile)"-1))"
and this doesn't work.)
-----
Incidentally the example code above is a reduced-to-simplest-form alteration of [this function](https://stackoverflow.com/a/35882480/5419599) that I just posted on Stack Overflow.
Asked by Wildcard
(37446 rep)
Mar 9, 2016, 03:52 AM
Last activity: Mar 11, 2016, 01:46 AM
Last activity: Mar 11, 2016, 01:46 AM