Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash: Fix bashisms being applied to non-bash shells #4334

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Check notice on line 1 in packages/b/bash/package.yml

View workflow job for this annotation

GitHub Actions / Checks

This package is included in the ISO. Consider validating the functionality in a newly built ISO.
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>solus@reillybrogan.com</Email>
<Name>Tracey Clark</Name>
<Email>traceyc.dev@tlcnet.info</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>solus@reillybrogan.com</Email>
<Name>Tracey Clark</Name>
<Email>traceyc.dev@tlcnet.info</Email>
</Update>
</History>
</PISI>
47 changes: 2 additions & 45 deletions packages/z/zsh/files/zprofile
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,5 @@ elif [ -f /etc/zsh/zprofile ]; then
source /etc/zsh/zprofile
fi

# Source paths that may not be included by systemctl
if [ -f /usr/share/defaults/etc/profile.d/10-path.sh ]; then
emulate sh -c 'source /usr/share/defaults/etc/profile.d/10-path.sh'
fi

# Source paths not included by systemctl necessary for XDG_DATA_DIRS

if [ -f /usr/share/defaults/etc/profile.d/10-xdg.sh ]; then
emulate sh -c 'source /usr/share/defaults/etc/profile.d/10-xdg.sh'
fi

# Source paths not included by systemctl necessary for flatpaks to be found in the app menu and run

if [ -f /usr/share/defaults/etc/profile.d/70-flatpak.sh ]; then
emulate sh -c 'source /usr/share/defaults/etc/profile.d/70-flatpak.sh'
fi

# Source paths not included by systemctl necessary for snaps to be found in the app menu and run

if [ -f /usr/share/defaults/etc/profile.d/70-snapd.sh ]; then
emulate sh -c 'source /usr/share/defaults/etc/profile.d/70-snapd.sh'
fi

# Source gtk modules variable for menus

if [ -f /usr/share/defaults/etc/profile.d/appmenu-gtk2-module.sh ]; then
emulate sh -c 'source /usr/share/defaults/etc/profile.d/appmenu-gtk2-module.sh'
fi

# Paths for gawk

if [ -f /usr/share/defaults/etc/profile.d/gawk.sh ]; then
emulate sh -c 'source /usr/share/defaults/etc/profile.d/gawk.sh'
fi

# Environment for vte, zsh compatible

if [ -f /usr/share/defaults/etc/profile.d/vte.sh ]; then
source /usr/share/defaults/etc/profile.d/vte.sh
fi

# Do not source /etc/profile as Arch does
# This will source all other bash scripts in /etc/profile.d, some of which may not load properly.
# Some may also conflict with zsh frameworks or have other unintended consequences
# Additionally, Solus sources ~/.bashrc.d from /etc/profile which is not obvious to the user or expected in zsh
# This should always be sourced regardless of the above files
emulate sh -c 'source /usr/share/defaults/etc/profile'
2 changes: 1 addition & 1 deletion packages/z/zsh/package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name : zsh
version : '5.9'
release : 34
release : 35
source :
- https://sourceforge.net/projects/zsh/files/zsh/5.9/zsh-5.9.tar.xz : 9b8d1ecedd5b5e81fbf1918e876752a7dd948e05c1a0dba10ab863842d45acd5
homepage : https://www.zsh.org/
Expand Down
4 changes: 2 additions & 2 deletions packages/z/zsh/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,8 @@
</Files>
</Package>
<History>
<Update release="34">
<Date>2024-11-11</Date>
<Update release="35">
<Date>2024-11-12</Date>
<Version>5.9</Version>
<Comment>Packaging update</Comment>
<Name>Tracey Clark</Name>
Expand Down