Top level: I have a script that works fine when run from the command line (which is the bash shell), but doesn't work when run under "at" (where it is run under /bin/sh, which is actually a symlink to dash). The script's different behavior happens despite the fact that it starts with a shebang pointing to /usr/bin/bash. I'm puzzled, and hoping someone with more shell knowledge can shed some light.
There are discussions in this vicinity - around bash and sh as a symlink (see here for one of themhttps://unix.stackexchange.com/question ... pliance-so, but they don't help me to understand my problem.
I just know that when I change the /usr/bin/sh symlink to point to bash instead of dash, my script works under at. I have no idea what havoc this might cause for other user scripts, or for Raspberry Pi OS itself.
Or it could be something I'm doing in my script. (Which is to restore a custom splash.png for plymouth, after mine gets overwritten by an update of the standard RPi one, AND to run update-initramfs so the custom splash appears on boot as well as shutdown. See here: viewtopic.php?p=2242362&hilit=splash.png#p2242362)
The problem behavior is that the sudo update-initramfs doesn't run, when under at, with /usr/bin/sh as a symlink to dash.
There are discussions in this vicinity - around bash and sh as a symlink (see here for one of themhttps://unix.stackexchange.com/question ... pliance-so, but they don't help me to understand my problem.
I just know that when I change the /usr/bin/sh symlink to point to bash instead of dash, my script works under at. I have no idea what havoc this might cause for other user scripts, or for Raspberry Pi OS itself.
Or it could be something I'm doing in my script. (Which is to restore a custom splash.png for plymouth, after mine gets overwritten by an update of the standard RPi one, AND to run update-initramfs so the custom splash appears on boot as well as shutdown. See here: viewtopic.php?p=2242362&hilit=splash.png#p2242362)
The problem behavior is that the sudo update-initramfs doesn't run, when under at, with /usr/bin/sh as a symlink to dash.
Code:
#!/usr/bin/bash# script to check if a custom splash image has been over-written, # if so, it restores it AND updates the initramfs so that# the custom image appears during both shutdown and bootWRKDIR=/usr/share/plymouth/themes/pixif [[ $# -eq 0 ]] ; then echo "Missing parameter for the custom splash image, i.e. /home/pi/mysplash.png" exit 1else MYSPLASH=$1ficd $WRKDIRif cmp --silent splash.png $MYSPLASH &> /dev/null then # equal echo never mind, splash is OKelse # not equal sudo cp -p $MYSPLASH splash.png sudo update-initramfs -ufiexit 0
Statistics: Posted by tinker2much — Tue Aug 06, 2024 11:12 am