How To Keep Personal Custom Bash Shell File's Automatically Updated

Lubuntu 24.04 LTS

Is there a way to have my personal custom bash shell file’s be automatically updated when bash goes through a version upgrade?

Which files do you mean? The config is in $HOME/.bashrc if that’s what you mean and is unmodified by updates.

When bash went through a version upgrade, some of us were caught not ready for it and found out the upgrade had rendered our personal bash script file’s a bit to where they weren’t functioning the commands the same way they did before.

So we had to go through them changing the commands line by line to match the “new at that time” commands.

Here’s one of my personal command files that contain the commands that no longer functions the same way as *buntu 22.04…
The only thing so far that I know of for certain is that xclip needs to be installed for it to be functional.

Recipe code

# PrtScr and Alt-PrtScr
# These are keyboard shortcuts for making a graphic copy of the full screen or the currently active window.
# With just one keystroke, you can copy the screen/window,
# and with a further keystroke (Ctrl-V), or a „Paste“ command, insert the graphics into any program of your choice (LibreOffice, KolourPaint etc…).
# Extremely useful, and standard in Win installations, but unfortunately not a default feature in Lubuntu/LXQt.
# It‘s not a big effort to create the keyboard shortcuts, though.

# First, make certain that scrot and xclip are installed.
# Then, using:
# Preferences → LXQt Settings → Shortcut Keys
# Assign the following command to the „PrtScr“ key:
# $   sh -c 'scrot -o /tmp/clip_$(id -u) -e 'xclip -selection clipboard -t image/png < $f''
# And this command to the „Alt-PrtScr“ key:
# $   sh -c 'scrot -o -u /tmp/clip_$(id -u) -e 'xclip -selection clipboard -t image/png < $f''
# Reboot (to clear /tmp).
# Done.

You’re not really describing something that can be automatically “fixed” by Bash itself when Bash is upgraded.

A few important points you can mention in your reply:

  • Bash upgrades do not modify your personal scripts in $HOME. What usually changes is:

    • external commands (scrot, xclip, sed, grep, coreutils, etc.)
    • default desktop / session behavior (LXQt vs older LXDE, Wayland vs X11, key handling)
  • Because of that, Bash has no way to automatically update custom scripts to match changed command behavior.

What does help in practice:

  • Keep personal scripts separate from .bashrc and source them:

    source ~/.bash_custom
    
  • Add dependency checks inside scripts, for example:

    command -v xclip >/dev/null || echo "xclip not installed"
    
  • Comment scripts clearly (as you already do :+1:) so updating them after a release upgrade is easier.

  • After a distro upgrade, quickly test scripts manually or with a small test wrapper.

In your specific example, the issue is not Bash, but missing or changed external tools (xclip, scrot, clipboard handling in LXQt). Those are expected to change between *buntu 22.04 → 24.04.

So the honest answer is:
:arrow_right: there’s no automatic update mechanism, but good scripting practices can make upgrades far less painful.

3 Likes

Just a nitpick: you’re executing your command with ‘sh’, which probably is not bash but dash (Debian Almquist Shell). Dash is specifically written to be compatible to the original Bourne Shell and will probably never get additional features only bugfixes. But even if /usr/bin/sh was a symlink to Bash, that shell is able to tell if it’s called as sh and will then run in POSIX compatible mode.

1 Like

Though not an actual solution, the following seems to be closest to a solution.

Better practices out-weighed my “idea” of “personal custom script auto-updating”.

Marking this post as a solution.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.