mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
benchmarks/driver.sh: quote path to fish if necessary
To allow paths with spaces, give a shell-quoted path to hyperfine. We could make this a bit shorter by quoting as early as possible, like FISH_PATH=$(quote "$1") and then use $FISH_PATH unquoted. I discarded that idea because it probably looks surprising. Closes #8559
This commit is contained in:
parent
0d67dd19a1
commit
db7bea1a3e
1 changed files with 14 additions and 4 deletions
|
@ -9,20 +9,30 @@ FISH_PATH=$1
|
|||
FISH2_PATH=$2
|
||||
BENCHMARKS_DIR=$(dirname "$0")/benchmarks
|
||||
|
||||
quote() {
|
||||
# Single-quote the given string for a POSIX shell, except in common cases that don't need it.
|
||||
printf %s "$1" |
|
||||
sed "/[^[:alnum:]\/.-]/ {
|
||||
s/'/'\\\''/g
|
||||
s/^/'/
|
||||
s/\$/'/
|
||||
}"
|
||||
}
|
||||
|
||||
for benchmark in "$BENCHMARKS_DIR"/*; do
|
||||
basename "$benchmark"
|
||||
[ -n "$FISH2_PATH" ] && echo "$FISH_PATH"
|
||||
${FISH_PATH} --print-rusage-self "$benchmark" > /dev/null
|
||||
"${FISH_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
echo "$FISH2_PATH"
|
||||
${FISH2_PATH} --print-rusage-self "$benchmark" > /dev/null
|
||||
"${FISH2_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
||||
fi
|
||||
|
||||
if command -v hyperfine >/dev/null 2>&1; then
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null" "${FISH2_PATH} $benchmark > /dev/null"
|
||||
hyperfine "$(quote "${FISH_PATH}") $benchmark > /dev/null" "$(quote "${FISH2_PATH}") $benchmark > /dev/null"
|
||||
else
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null"
|
||||
hyperfine "$(quote "${FISH_PATH}") $benchmark > /dev/null"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue