Skip to content

Commit

Permalink
More quoting fixes for handling paths with spaces (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsharpe authored Jan 2, 2022
1 parent 5f37b42 commit ae4ff42
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions foreign_cc/private/framework/toolchains/freebsd_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if [ -d "$1" ]; then
SAVEIFS=$IFS
IFS=$'\n'
# Find all real files. Symlinks are assumed to be relative to something within the directory we're seaching and thus ignored
local files=$(find -P -f $1 \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
local files=$(find -P -f "$1" \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
IFS=$SAVEIFS
for file in ${files[@]}; do
local backup=$(mktemp)
Expand All @@ -103,7 +103,7 @@ if [[ -d "{source}" ]]; then
else
cp -L -R "{source}" "{target}"
fi
find {target} -type f -exec touch -r "{source}" "{{}}" \\;
find "{target}" -type f -exec touch -r "{source}" "{{}}" \\;
""".format(
source = source,
target = target,
Expand Down Expand Up @@ -216,7 +216,7 @@ def cleanup_function(on_success, on_failure):
def children_to_path(dir_):
text = """\
if [ -d {dir_} ]; then
local tools=$(find $EXT_BUILD_DEPS/bin/ -maxdepth 1 -mindepth 1)
local tools=$(find "$EXT_BUILD_DEPS/bin/" -maxdepth 1 -mindepth 1)
for tool in $tools;
do
if [[ -d \"$tool\" ]] || [[ -L \"$tool\" ]]; then
Expand Down
8 changes: 4 additions & 4 deletions foreign_cc/private/framework/toolchains/linux_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if [ -d "$1" ]; then
SAVEIFS=$IFS
IFS=$'\n'
# Find all real files. Symlinks are assumed to be relative to something within the directory we're seaching and thus ignored
local files=$(find -P $1 \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
local files=$(find -P "$1" \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
IFS=$SAVEIFS
for file in ${files[@]}; do
local backup=$(mktemp)
Expand All @@ -86,7 +86,7 @@ fi
)

def copy_dir_contents_to_dir(source, target):
return """cp -L -r --no-target-directory "{source}" "{target}" && find {target} -type f -exec touch -r "{source}" "{{}}" \\;""".format(
return """cp -L -r --no-target-directory "{source}" "{target}" && find "{target}" -type f -exec touch -r "{source}" "{{}}" \\;""".format(
source = source,
target = target,
)
Expand Down Expand Up @@ -166,7 +166,7 @@ def script_prelude():

def increment_pkg_config_path(source):
text = """\
local children=$(find $1 -mindepth 1 -name '*.pc')
local children=$(find "$1" -mindepth 1 -name '*.pc')
# assume there is only one directory with pkg config
for child in $children; do
export PKG_CONFIG_PATH="$${PKG_CONFIG_PATH:-}$$:$(dirname $child)"
Expand Down Expand Up @@ -198,7 +198,7 @@ def cleanup_function(on_success, on_failure):
def children_to_path(dir_):
text = """\
if [ -d {dir_} ]; then
local tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
local tools=$(find "$EXT_BUILD_DEPS/bin" -maxdepth 1 -mindepth 1)
for tool in $tools;
do
if [[ -d \"$tool\" ]] || [[ -L \"$tool\" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions foreign_cc/private/framework/toolchains/macos_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if [ -d "$1" ]; then
SAVEIFS=$IFS
IFS=$'\n'
# Find all real files. Symlinks are assumed to be relative to something within the directory we're seaching and thus ignored
local files=$(find -P -f $1 \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
local files=$(find -P -f "$1" \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
IFS=$SAVEIFS
for file in ${files[@]}; do
local backup=$(mktemp)
Expand All @@ -94,7 +94,7 @@ if [[ -d "{source}" ]]; then
else
cp -L -R "{source}" "{target}"
fi
find {target} -type f -exec touch -r "{source}" "{{}}" \\;
find "{target}" -type f -exec touch -r "{source}" "{{}}" \\;
""".format(
source = source,
target = target,
Expand Down Expand Up @@ -207,7 +207,7 @@ def cleanup_function(on_success, on_failure):
def children_to_path(dir_):
text = """\
if [ -d {dir_} ]; then
local tools=$(find $EXT_BUILD_DEPS/bin/ -maxdepth 1 -mindepth 1)
local tools=$(find "$EXT_BUILD_DEPS/bin/" -maxdepth 1 -mindepth 1)
for tool in $tools;
do
if [[ -d \"$tool\" ]] || [[ -L \"$tool\" ]]; then
Expand Down
8 changes: 4 additions & 4 deletions foreign_cc/private/framework/toolchains/windows_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if [ -d "$1" ]; then
SAVEIFS=$IFS
IFS=$'\n'
# Find all real files. Symlinks are assumed to be relative to something within the directory we're seaching and thus ignored
local files=$($REAL_FIND -P $1 -type f \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
local files=$($REAL_FIND -P "$1" -type f \\( -type f -and \\( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.mk" -or -name "*.cmake" \\) \\))
IFS=$SAVEIFS
# Escape any backslashes so sed can understand what it's supposed to replace
local argv2=$(echo "$2" | sed 's/\\\\/\\\\\\\\/g')
Expand All @@ -90,7 +90,7 @@ fi
)

def copy_dir_contents_to_dir(source, target):
return """cp -L -r --no-target-directory "{source}" "{target}" && find {target} -type f -exec touch -r "{source}" "{{}}" \\;""".format(
return """cp -L -r --no-target-directory "{source}" "{target}" && $REAL_FIND "{target}" -type f -exec touch -r "{source}" "{{}}" \\;""".format(
source = source,
target = target,
)
Expand Down Expand Up @@ -180,7 +180,7 @@ export SYSTEMDRIVE="C:"

def increment_pkg_config_path(source):
text = """\
local children=$($REAL_FIND $1 -mindepth 1 -name '*.pc')
local children=$($REAL_FIND "$1" -mindepth 1 -name '*.pc')
# assume there is only one directory with pkg config
for child in $children; do
export PKG_CONFIG_PATH="$${PKG_CONFIG_PATH:-}$$:$(dirname $child)"
Expand Down Expand Up @@ -212,7 +212,7 @@ def cleanup_function(on_success, on_failure):
def children_to_path(dir_):
text = """\
if [ -d {dir_} ]; then
local tools=$($REAL_FIND $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
local tools=$($REAL_FIND "$EXT_BUILD_DEPS/bin" -maxdepth 1 -mindepth 1)
for tool in $tools;
do
if [[ -d \"$tool\" ]] || [[ -L \"$tool\" ]]; then
Expand Down

0 comments on commit ae4ff42

Please sign in to comment.