Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit f1cc7f7

Browse files
committed
lib/builtins.sh: add ab_trim_args function ...
... this function trims inner whitespaces inside a string
1 parent 3d64896 commit f1cc7f7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/builtins.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,13 @@ ab_match_archgroup() {
7474
abinfo "All architecture group members '${ABHOST_GROUP//$'\n'/,}' mismatches $1: taking false branch."
7575
return 1
7676
}
77+
78+
## ab_trim_args var
79+
## Minimize the whitespace characters inside the variable "$var"
80+
## NOTE: This function modifies the variable IN-PLACE and does not return any value.
81+
## Example: ab_trim_args CFLAGS
82+
ab_trim_args() {
83+
local arg
84+
declare -n arg="$1"
85+
arg="$(tr -s ' ' <<< "${arg}")"
86+
}

proc/12-arch_flags.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ for ABFLAG in {LD,C{,PP,XX},OBJC{,XX},RUST}FLAGS; do
5757
declare -n FLAG="$ABFLAG";
5858
FLAG+="${_flags_weird_buf[_flags_current_i]}"; ((_flags_current_i++));
5959
unset -n FLAG;
60+
ab_trim_args "$ABFLAG";
6061
done
6162
unset ABCC _flags_current_i

0 commit comments

Comments
 (0)