I have a shell script (arch-chroot
from the Arch Linux arch-install-scripts
package) that handles the mounting and unmounting of devices (with error checking) prior to starting a chroot
. It starts the chroot
on the final line with:
SHELL=/bin/sh unshare --fork --pid chroot "$chrootdir" "$@"
For my use case, I would like to use the exact same script with a "patch" to the final line
SHELL=/bin/bash chroot "$chrootdir" "$@"
What is the best way to do this? If it matters, the arch-chroot
script needs to be run with root privileges. Right now I just have a patched copy of the script. If the original script gets updated, then my patched version will be "out of date". I was thinking I could do the copy and patch as needed in a temporary location, but I am not sure if that is better.
Is there a way to temporarily patch a script inplace?
The original script will only be changed when the package it belongs to is updated. My goal is to keep the original script unchanged but have a way of calling a patched version of the most recent version of the original script.
patch
and need strategic help or don't know how to usepatch
and need syntactic help. – depquid Jan 28 '16 at 19:36patch
/sed
, I just don't know "when" I should apply the patch and if I need a temporary/permanent file. – StrongBad Jan 28 '16 at 19:39