Skip to content

Commit 4a3d708

Browse files
committed
bbb: Update to handle multiple strings
1 parent ac86ae0 commit 4a3d708

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

terminal/bbb.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ if ${missing_dependencies}; then
2828
fail 'Please install the missing dependencies!'
2929
fi
3030

31+
declare -a INPUT
3132
if [[ -p /dev/stdin ]]; then
32-
INPUT="$(cat -)"
33+
readarray -t INPUT
3334
else
34-
INPUT="${*}"
35+
INPUT=("${@}")
3536
fi
37+
declare -r INPUT
3638

37-
# Add missing padding.
38-
# This is commonly reqired when grabbing b64 strings from a JWT.
39-
while [[ $(( ${#INPUT} % 4 )) -ne 0 ]]; do
40-
INPUT+='='
39+
for line in "${INPUT[@]//\"}"; do # Trim "
40+
while [[ $(( ${#line} % 4 )) -ne 0 ]]; do
41+
line+='=' # Add missing padding
42+
done
43+
base64 -d <<< "${line}"
44+
printf '\n'
4145
done
42-
43-
echo -n "${INPUT}" | base64 -d ; echo

0 commit comments

Comments
 (0)