Skip to content

Commit

Permalink
bash: Fix bashisms being applied to non-bash shells
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tracey Clark authored and TraceyC77 committed Jan 1, 2025
1 parent de1249f commit 543e057
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
5 changes: 4 additions & 1 deletion packages/b/bash/files/profile/50-history.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion packages/b/bash/files/profile/50-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions packages/b/bash/files/profile/README.md
Original file line number Diff line number Diff line change
@@ -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
```
10 changes: 0 additions & 10 deletions packages/b/bash/files/profile/profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions packages/b/bash/files/skel/.bashrc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion packages/b/bash/package.yml
Original file line number Diff line number Diff line change
@@ -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 :
Expand Down
14 changes: 7 additions & 7 deletions packages/b/bash/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Name>bash</Name>
<Homepage>https://www.gnu.org/software/bash</Homepage>
<Packager>
<Name>Reilly Brogan</Name>
<Email>[email protected]</Email>
<Name>Tracey Clark</Name>
<Email>[email protected]</Email>
</Packager>
<License>GPL-3.0-or-later</License>
<PartOf>system.base</PartOf>
Expand Down Expand Up @@ -135,7 +135,7 @@
</Description>
<PartOf>programming.devel</PartOf>
<RuntimeDependencies>
<Dependency release="84">bash</Dependency>
<Dependency release="85">bash</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="header">/usr/include/bash/alias.h</Path>
Expand Down Expand Up @@ -201,12 +201,12 @@
</Files>
</Package>
<History>
<Update release="84">
<Date>2024-10-18</Date>
<Update release="85">
<Date>2024-11-12</Date>
<Version>5.2.37</Version>
<Comment>Packaging update</Comment>
<Name>Reilly Brogan</Name>
<Email>[email protected]</Email>
<Name>Tracey Clark</Name>
<Email>[email protected]</Email>
</Update>
</History>
</PISI>

0 comments on commit 543e057

Please sign in to comment.