mirror of
https://github.com/rust-lang/book.git
synced 2026-12-03 04:45:08 -06:00
Use single quotes when shell expansions aren't needed
This commit is contained in:
@@ -37,16 +37,16 @@ find -s listings -name output.txt -print0 | while IFS= read -r -d '' f; do
|
||||
cd $tmp_build_directory
|
||||
|
||||
# Save the previous compile time; we're going to keep it to minimize diff churn
|
||||
compile_time=$(sed -E -ne "s/.*Finished (dev|test) \[unoptimized \+ debuginfo] target\(s\) in ([0-9.]*).*/\2/p" ${full_output_path})
|
||||
compile_time=$(sed -E -ne 's/.*Finished (dev|test) \[unoptimized \+ debuginfo] target\(s\) in ([0-9.]*).*/\2/p' ${full_output_path})
|
||||
|
||||
# Save the hash from the first test binary; we're going to keep it to minimize diff churn
|
||||
test_binary_hash=$(sed -E -ne "s@.*Running target/debug/deps/[^-]*-([^\s]*)@\1@p" ${full_output_path} | head -n 1)
|
||||
test_binary_hash=$(sed -E -ne 's@.*Running target/debug/deps/[^-]*-([^\s]*)@\1@p' ${full_output_path} | head -n 1)
|
||||
|
||||
# Act like this is the first time this listing has been built
|
||||
cargo clean
|
||||
|
||||
# Run the command in the existing output file
|
||||
cargo_command=$(sed -ne "s/$ \(.*\)/\1/p" ${full_output_path})
|
||||
cargo_command=$(sed -ne 's/$ \(.*\)/\1/p' ${full_output_path})
|
||||
|
||||
# Clear the output file of everything except the command
|
||||
echo "$ ${cargo_command}" > ${full_output_path}
|
||||
@@ -58,7 +58,7 @@ find -s listings -name output.txt -print0 | while IFS= read -r -d '' f; do
|
||||
|
||||
# Set the project file path to the projects directory plus the crate name instead of a path
|
||||
# to the computer of whoever is running this
|
||||
sed -i '' -E -e "s@(Compiling|Checking) ([^\)]*) v0.1.0 (.*)@\1 \2 v0.1.0 (file:///projects/\2)@" ${full_output_path}
|
||||
sed -i '' -E -e 's@(Compiling|Checking) ([^\)]*) v0.1.0 (.*)@\1 \2 v0.1.0 (file:///projects/\2)@' ${full_output_path}
|
||||
|
||||
# Restore the previous compile time, if there is one
|
||||
if [ -n "${compile_time}" ]; then
|
||||
@@ -67,7 +67,10 @@ find -s listings -name output.txt -print0 | while IFS= read -r -d '' f; do
|
||||
|
||||
# Restore the previous test binary hash, if there is one
|
||||
if [ -n "${test_binary_hash}" ]; then
|
||||
sed -i '' -E -e "s@Running target/debug/deps/([^-]*)-([^\s]*)$@Running target/debug/deps/\1-${test_binary_hash}@g" ${full_output_path}
|
||||
replacement='s@Running target/debug/deps/([^-]*)-([^\s]*)$@Running target/debug/deps/\1-'
|
||||
replacement+="${test_binary_hash}"
|
||||
replacement+='@g'
|
||||
sed -i '' -E -e "${replacement}" ${full_output_path}
|
||||
fi
|
||||
|
||||
cd - > /dev/null
|
||||
|
||||
Reference in New Issue
Block a user