On 15.05.2018 17:27, Pat Rankin wrote:
> [...]
>
> There's been at least one report that failing to specify any hints file
> doesn't work any more even though it's supposed to be optional.
> (Something about the script's use of /dev/null as a placeholder and
> some system not liking the way that's being used by [ -f ]. I'm not
> sure of the details aside from the fact that whatever the issue is, it
> hasn't been fixed yet. I won't be surprised if cygwin is the system
> that has the problem.)
Well, the logic
if [ ! -f /dev/null ] ; then echo "no file" ; fi
will produce (with modern shells, on linux) "no file". That means that
using a default setup.sh call (i.e. without arguments) will always fail
due to the if-test that follows the case-statement. Relocating the if-
condition into the case branch might already fix that inherent problem.
case "x$1" in
x) hints=/dev/null
hfile=/dev/null
;;
*) hints=$prefix/$1
hfile=$1
if [ ! -f "$hints" ]; then
echo "Cannot find hints file $hfile"
exit 1
fi
;;
esac
Another option could be to check for the "/dev/null" special case in the
if-statement to prevent the exit in case the default is used.
if [ ! -f "$hints" ] && [ "$hints" != "/dev/null" ]; then
echo "Cannot find hints file $hfile"
exit 1
fi
It seems that the mkmkfile.sh program will not mind a "/dev/null" being
passed as argument, although the awk calls
awk '/^#-POST/,/^#-PRE/{ \
if(index($0, "#-POST") == 1) print "# (new segment at source
line",NR,")"; \
if(index($0, "#-P") != 1) print}' $4 >> $3
(with $4 expanded to /dev/null) will not contribute any content then.
(Not sure if that's intended. I'm too lazy to dive into that.)
Janis