From 543e05707c061595a58631fabf9e19a2e1ad7eea Mon Sep 17 00:00:00 2001 From: Tracey Clark Date: Mon, 11 Nov 2024 20:13:58 -0600 Subject: [PATCH] bash: Fix bashisms being applied to non-bash shells Move sourcing of bashrc.d directory to default skel/.bashrc Make all scripts in profile.d POSIX compliant Fixes issues with errors being emitted by non-bash shells Fixes bash specific user scripts improperly being loaded by other shells Add README for profile.d files needing to be POSIX compliant --- packages/b/bash/files/profile/50-history.sh | 5 ++++- packages/b/bash/files/profile/50-prompt.sh | 3 ++- packages/b/bash/files/profile/README.md | 10 ++++++++++ packages/b/bash/files/profile/profile | 10 ---------- packages/b/bash/files/skel/.bashrc | 10 ++++++++++ packages/b/bash/package.yml | 2 +- packages/b/bash/pspec_x86_64.xml | 14 +++++++------- 7 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 packages/b/bash/files/profile/README.md diff --git a/packages/b/bash/files/profile/50-history.sh b/packages/b/bash/files/profile/50-history.sh index 2e6bba78735..72a91d2e43a 100644 --- a/packages/b/bash/files/profile/50-history.sh +++ b/packages/b/bash/files/profile/50-history.sh @@ -1,7 +1,10 @@ # Begin /usr/share/defaults/etc/profile.d/50-history.sh # Append to history file on exit instead of overwrite (parallel terminals) -shopt -s histappend +# shopt is bash only +if [ $SHELL = "/usr/bin/bash" ]; then + shopt -s histappend +fi export HISTSIZE=1500 export HISTIGNORE="&:[bf]g:exit" diff --git a/packages/b/bash/files/profile/50-prompt.sh b/packages/b/bash/files/profile/50-prompt.sh index ac7d4aa8b85..bbc64404ca0 100644 --- a/packages/b/bash/files/profile/50-prompt.sh +++ b/packages/b/bash/files/profile/50-prompt.sh @@ -16,7 +16,8 @@ unset FG unset BG unset AT unset HCOLOR -if [ $SHELL != "/bin/zsh" ]; then +# shopt is bash only +if [ $SHELL = "/usr/bin/bash" ]; then shopt -s checkwinsize fi diff --git a/packages/b/bash/files/profile/README.md b/packages/b/bash/files/profile/README.md new file mode 100644 index 00000000000..c2a480dc6ba --- /dev/null +++ b/packages/b/bash/files/profile/README.md @@ -0,0 +1,10 @@ +Files in this directory must have code that is POSIX compliant, since the file is loaded by all BOURNE compatible shells +If you must use a bash-only function like shopt it must be put in a block that will load it only for bash + +e.g. + +``` +if [ $SHELL = "/usr/bin/bash" ]; then + shopt -s checkwinsize +fi +``` diff --git a/packages/b/bash/files/profile/profile b/packages/b/bash/files/profile/profile index 5460d38457a..1fbfaca122b 100644 --- a/packages/b/bash/files/profile/profile +++ b/packages/b/bash/files/profile/profile @@ -19,14 +19,4 @@ if [ -d /etc/profile.d ] ; then unset script fi -# User specific aliases and functions -if [ -d ~/.bashrc.d ]; then - for rc in ~/.bashrc.d/*; do - if [ -f "$rc" ]; then - . "$rc" - fi - done - unset rc -fi - # End /usr/share/defaults/etc/profile diff --git a/packages/b/bash/files/skel/.bashrc b/packages/b/bash/files/skel/.bashrc index fad2b4be5e7..7242c115cb1 100644 --- a/packages/b/bash/files/skel/.bashrc +++ b/packages/b/bash/files/skel/.bashrc @@ -1 +1,11 @@ source /usr/share/defaults/etc/profile + +# User specific bash aliases and functions +if [ -d ~/.bashrc.d ]; then + for rc in ~/.bashrc.d/*; do + if [ -f "$rc" ]; then + . "$rc" + fi + done + unset rc +fi diff --git a/packages/b/bash/package.yml b/packages/b/bash/package.yml index 816db12cd86..6e0b1ff151c 100644 --- a/packages/b/bash/package.yml +++ b/packages/b/bash/package.yml @@ -1,6 +1,6 @@ name : bash version : 5.2.37 -release : 84 +release : 85 source : - https://ftp.gnu.org/gnu/bash/bash-5.2.37.tar.gz : 9599b22ecd1d5787ad7d3b7bf0c59f312b3396d1e281175dd1f8a4014da621ff license : diff --git a/packages/b/bash/pspec_x86_64.xml b/packages/b/bash/pspec_x86_64.xml index 940e093769a..f0e8698eae6 100644 --- a/packages/b/bash/pspec_x86_64.xml +++ b/packages/b/bash/pspec_x86_64.xml @@ -3,8 +3,8 @@ bash https://www.gnu.org/software/bash - Reilly Brogan - solus@reillybrogan.com + Tracey Clark + traceyc.dev@tlcnet.info GPL-3.0-or-later system.base @@ -135,7 +135,7 @@ programming.devel - bash + bash /usr/include/bash/alias.h @@ -201,12 +201,12 @@ - - 2024-10-18 + + 2024-11-12 5.2.37 Packaging update - Reilly Brogan - solus@reillybrogan.com + Tracey Clark + traceyc.dev@tlcnet.info \ No newline at end of file