aboutsummaryrefslogtreecommitdiff
path: root/lib/util.bash
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-05-21 12:24:01 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-05-21 12:25:49 +0200
commit3a84a21b063739b5586b4455d96a1e79cff93ad8 (patch)
tree54e077183aa1db31fcf9ad815576b112156abf0d /lib/util.bash
parenta90e94c845cded2aeda7b70ea3ec5d6b6085f44a (diff)
Add chomp util
Diffstat (limited to 'lib/util.bash')
-rw-r--r--lib/util.bash5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/util.bash b/lib/util.bash
index c2429a1..7bc8a6d 100644
--- a/lib/util.bash
+++ b/lib/util.bash
@@ -18,6 +18,11 @@ chgdir() {
cd -- "$1" || die "Failed to change directory to $1"
}
+# Removes whitespace surrounding a given text.
+chomp() {
+ awk '{$1=$1};1' <<< "$@"
+}
+
# Create a datetime stamp. This is a wrapper around the date utility, ensuring
# that the date being formatted is always in UTC and respect SOURCE_DATE_EPOCH,
# if it is set.