forked from Dicklesworthstone/agentic_coding_flywheel_setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_escaping.sh
More file actions
41 lines (33 loc) · 890 Bytes
/
test_escaping.sh
File metadata and controls
41 lines (33 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
shell_escape_args() {
local out=""
local arg=""
local q=""
for arg in "$@"; do
printf -v q '%q' "$arg"
if [[ -n "$out" ]]; then
out+=" "
fi
out+="$q"
done
printf '%s' "$out"
}
# Simulate the array in acfs_container.sh
install_args=(--local --yes --mode vibe --skip-ubuntu-upgrade)
echo " Original array: ${install_args[*]}"
escaped="$(shell_escape_args "${install_args[@]}")"
echo "Escaped string: $escaped"
# Simulate what acfs_sandbox_exec_root does (bash -c "$cmd")
# We'll use a dummy install.sh that just prints its args
cat > dummy_install.sh <<'EOF'
#!/bin/bash
echo "Dummy Install receives $# args:"
for arg in "$@"; do
echo " Arg: '$arg'"
done
EOF
chmod +x dummy_install.sh
echo "--- Testing bash -c execution ---"
cmd="bash dummy_install.sh $escaped"
echo "Command: $cmd"
bash -c "$cmd"