Fix order of -maxdepth find argument

Gnu find outputs a warning if the maxdepth option appears after any
positional options, such as filtering files, because maxdepth also
affects options that come before it.

As a side note, maxdepth appears to be gnu extension that busybox picked
up, so we might want to be careful about using it.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
This commit is contained in:
ArenM
2023-01-19 13:18:06 -05:00
committed by Willow Barraco
parent 9b9a31e542
commit 27c663a896
2 changed files with 3 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ mkdir -p "$XDG_CONFIG_HOME/sxmo/hooks/$SXMO_DEVICE_NAME"
[ -e off ] && mv off "$SXMO_DEVICE_NAME/sxmo_hook_screenoff.sh" [ -e off ] && mv off "$SXMO_DEVICE_NAME/sxmo_hook_screenoff.sh"
[ -e unlock ] && mv unlock "$SXMO_DEVICE_NAME/sxmo_hook_unlock.sh" [ -e unlock ] && mv unlock "$SXMO_DEVICE_NAME/sxmo_hook_unlock.sh"
find . -type f -maxdepth 1 -exec basename {} \; \ find . -maxdepth 1 -type f -exec basename {} \; \
| grep -v 'needs-migration$' \ | grep -v 'needs-migration$' \
| grep -v '^sxmo_hook_.*\.sh$' \ | grep -v '^sxmo_hook_.*\.sh$' \
| xargs -I{} mv {} sxmo_hook_{}.sh | xargs -I{} mv {} sxmo_hook_{}.sh

View File

@@ -10,7 +10,7 @@ set -e
# Find the hook by name in the current directory. # Find the hook by name in the current directory.
filename() { filename() {
find "$SXMO_DEVICE_NAME/" . -name "sxmo_hook_$1.sh" -maxdepth 1 | head -n1 find "$SXMO_DEVICE_NAME/" . -maxdepth 1 -name "sxmo_hook_$1.sh" | head -n1
} }
copy() { copy() {
@@ -20,7 +20,7 @@ copy() {
file="$(filename "$1")" file="$(filename "$1")"
if [ ! -e "$file" ]; then if [ ! -e "$file" ]; then
cd "$(xdg_data_path sxmo/default_hooks)" || return cd "$(xdg_data_path sxmo/default_hooks)" || return
file="$(find "$SXMO_DEVICE_NAME/" . -name "sxmo_hook_$1.sh" -maxdepth 1 | head -n1)" file="$(find "$SXMO_DEVICE_NAME/" . -maxdepth 1 -name "sxmo_hook_$1.sh" | head -n1)"
[ -e "$file" ] && cp "$file" "$XDG_CONFIG_HOME/sxmo/hooks/$file" [ -e "$file" ] && cp "$file" "$XDG_CONFIG_HOME/sxmo/hooks/$file"
fi fi
} }