Last active
June 4, 2020 16:17
-
-
Save cfraizer/8f17c375837f6d904bcafd3adaa8466d to your computer and use it in GitHub Desktop.
Compare "pure" Bash vs call to `tr`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
foo() { | |
local value="The Quick Brown FOX umped over The Lazy Dog." | |
local -i loopCount=1000 | |
local -i i=0 | |
for (( i = 0; i < loopCount; ++i )); do | |
local newVal="" | |
newVal="${value,,}" | |
printf "%s\n" "$newVal" | |
done | |
} | |
bar() { | |
local value="The Quick Brown FOX umped over The Lazy Dog." | |
local -i loopCount=1000 | |
local -i i=0 | |
for (( i = 0; i < loopCount; ++i )); do | |
# shellcheck disable=SC2155 | |
local newVal=$(echo "$value" | tr '[:upper:]' '[:lower:]') | |
printf "%s\n" "$newVal" | |
done | |
} | |
baz() { | |
local value="$*" | |
printf "%s\n" "${value,,}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment