Created
September 20, 2023 00:29
-
-
Save lazerl0rd/8160a76b75736a6c4f8247ac8198feba to your computer and use it in GitHub Desktop.
https://aur.archlinux.org/packages/dashbinsh but ~~better~~ automated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# shellcheck disable=SC2086 | |
readarray -t bashismUsers < <(IFS=:; grep -Irl -e '#!/bin/sh' -e '#! /bin/sh' -e '#!/usr/bin/env sh' -e '#! /usr/bin/env sh' $PATH | xargs -r checkbashisms 2>&1 | grep "possible bashism" 2>&1 | sed 's/^possible bashism in //g' | sed 's/ line.*$//g') | |
for i in "${bashismUsers[@]}"; do | |
echo "Modifying \"$i\" in-place to use Bash directly..." | |
sed -i 's/#!\/bin\/sh/#!\/bin\/bash/g' $i | |
sed -i 's/#! \/bin\/sh/#! \/bin\/bash/g' $i | |
sed -i 's/#!\/usr\/bin\/env sh/#!\/usr\/bin\/env bash/g' $i | |
sed -i 's/#! \/usr\/bin\/env sh/#! \/usr\/bin\/env bash/g' $i | |
done | |
ln -sfT "dash" "/usr/bin/sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trigger] | |
Type = Package | |
Operation = Install | |
Operation = Upgrade | |
Target = bash | |
[Action] | |
Description = Re-pointing /bin/sh symlink to dash... | |
When = PostTransaction | |
Exec = /usr/local/bin/dashasbinsh | |
Depends = dash checkbashisms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save
dashasbinsh
as/usr/local/bin/dashasbinsh
anddashasbinsh.hook
, as/etc/pacman.d/hooks/dashasbinsh.hook
, rundashasbinsh
as root, then sit back and forget.