# _LAST_PATCH being something like 00.0042. It is a real
# world example and as such not everything makes sense. _MAJOR for instance
# is just dead weight.
shopt -s extglob # To get support for more sophisticated pattern
_MAJOR=${_LAST_PATCH%%.+([0-9])} # Remove longest pattern match from behind
_MINOR=${_LAST_PATCH##+([0-9]).} # Remove longest pattern match from front
_MINOR=${_MINOR##+(0)} # Remove leading 0s
_MAJOR=${_MAJOR:-0} # If nothing remains, set to 0
_MINOR=${_MINOR:-0}
shopt -u extglob
# Generate the new minor number
((_MINOR += 1)) # Increment _MINOR
_MINOR=$(printf %04d ${_MINOR}) # left padding with 0. printf is a bash internal!
Thursday, 28 March 2019
[bash] String manipulation within
In stead of turning to subprocesses with sed and the like. Works at least as of version 4.2.46(2)
Subscribe to:
Posts (Atom)
[git] Create a local branch from another branch
From the active branch git checkout -b <LOCAL_BRANCH> From a donator branch git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH...
-
Abbreviations DWH: Data Warehouse (probably trivial when you were interested in reading so far 😉) KF: Point in time from when the recor...
-
I booted into a live USB Gentoo system, but even though I selected german key mapping just after the boot process started, the KDE desktop u...
-
Problem You were a bit hasty and committed and pushed something you should not have, e.g., as it has happened to me, into the wrong branch. ...