diff options
author | Slatian <baschdel@disroot.org> | 2023-12-01 22:10:18 +0100 |
---|---|---|
committer | Simon Lees <simon@simotek.net> | 2023-12-03 23:59:20 +0000 |
commit | 94e9d7b4c4c2c0c945de6936fad846f323a4fd40 (patch) | |
tree | 60f5348b0707d3ac8611142e7f5bfc16b8354705 | |
parent | 56ee8b38cafa8fda177492a66d1321de773756f9 (diff) |
Fix quoting issues in t-xdg-open.sh
This fixes autotests with Dash prior 0.5.11 and Bash of any version.
See also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=975228
Original patch by Nicolas Guriev.
Rebased and updated.
-rwxr-xr-x | autotests/t-xdg-open.sh | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/autotests/t-xdg-open.sh b/autotests/t-xdg-open.sh index 279eb77..f30623d 100755 --- a/autotests/t-xdg-open.sh +++ b/autotests/t-xdg-open.sh @@ -3,18 +3,22 @@ COMMAND_TESTED=xdg-open . ./test-lib.sh test_open_url() { - local de=$1 + local de cmd + de=$1 shift - local cmd=$1 + cmd=$1 - mock $cmd - run $de xdg-open http://www.freedesktop.org/ + mock "$cmd" + run "$de" xdg-open http://www.freedesktop.org/ assert_run "$@" http://www.freedesktop.org/ - unmock $cmd + unmock "$cmd" } mock_xdg_mime() { - local file="$1" mimetype="$2" handler="$3" + local file mimetype handler + file="$1" + mimetype="$2" + handler="$3" mock xdg-mime ' if [ $# = 3 ] && [ "$1" = query ] && [ "$2" = filetype ] && \ [ "$3" = '\'"$file"\'' ]; then @@ -30,23 +34,23 @@ fi } test_generic_open_file() { - local filename="$1" - echo foo > "$LABDIR/$1" - mock_xdg_mime "$LABDIR/$1" text/plain textedit + local filename + filename="$1" + echo foo > "$LABDIR/$filename" + mock_xdg_mime "$LABDIR/$filename" text/plain textedit mock_desktop_file textedit %f mock textedit - run generic xdg-open "$LABDIR/$1" - assert_run textedit "$LABDIR/$1" + run generic xdg-open "$LABDIR/$filename" + assert_run textedit "$LABDIR/$filename" } test_that_it opens a URL with "gio open" in recent GNOME 3, and Cinnamon -mock "gio open" -test_open_url gnome3 "gio open" -test_open_url cinnamon "gio open" +test_open_url gnome3 gio open +test_open_url cinnamon gio open test_that_it opens a URL with gvfs-open if "gio open" is missing in GNOME 3, \ GNOME 2, and Cinnamon -mock_missing "gio open" +mock_missing gio mock gvfs-open test_open_url gnome3 gvfs-open test_open_url gnome2 gvfs-open @@ -54,13 +58,13 @@ test_open_url cinnamon gvfs-open test_that_it opens a URL with gnome-open if "gio open" and gvfs-open are \ missing in GNOME 2 -mock_missing "gio open" +mock_missing gio mock_missing gvfs-open test_open_url gnome2 gnome-open test_that_it opens a URL with the generic method if "gio open" and gvfs-open \ are missing in GNOME 3, and Cinnamon -mock_missing "gio open" +mock_missing gio mock_missing gvfs-open mock gnome-open mock_desktop_file mosaic %u @@ -70,7 +74,7 @@ test_open_url cinnamon mosaic test_that_it opens a URL with the generic method if "gio open", gvfs-open and \ gnome-open are missing in GNOME 2 -mock_missing "gio open" +mock_missing gio mock_missing gvfs-open mock_missing gnome-open mock_desktop_file mosaic %u @@ -91,7 +95,7 @@ test_open_url mate gvfs-open test_that_it opens a URL with mate-open if "gio open" and gvfs-open are \ missing in MATE -mock_missing "gio open" +mock_missing gio mock_missing gvfs-open test_open_url mate mate-open @@ -103,15 +107,15 @@ test_open_url enlightenment enlightenment_open test_that_it opens a file path with pcmanfm in LXDE mock pcmanfm -touch $LABDIR/file.txt -run lxde xdg-open $LABDIR/file.txt -assert_run pcmanfm $(pwd)/$LABDIR/file.txt +touch "$LABDIR/file.txt" +run lxde xdg-open "$LABDIR/file.txt" +assert_run pcmanfm "$(pwd)/$LABDIR/file.txt" test_that_it percent-decodes a file:// URL and opens it with pcmanfm in LXDE mock pcmanfm -touch $LABDIR/file.txt -run lxde xdg-open file://$(pwd)/$LABDIR/file%2etxt -assert_run pcmanfm $(pwd)/$LABDIR/file.txt +touch "$LABDIR/file.txt" +run lxde xdg-open "file://$(pwd)/$LABDIR/file%2etxt" +assert_run pcmanfm "$(pwd)/$LABDIR/file.txt" test_that_it opens files with spaces in their name in LXDE echo foo > "$LABDIR/test file.txt" @@ -158,6 +162,6 @@ test_generic_open_file 'test file.txt' test_that_it opens file://localhost/ paths mock pcmanfm -touch $LABDIR/file.txt -run lxde xdg-open file://localhost$(pwd)/$LABDIR/file%2etxt -assert_run pcmanfm $(pwd)/$LABDIR/file.txt +touch "$LABDIR/file.txt" +run lxde xdg-open "file://localhost$(pwd)/$LABDIR/file%2etxt" +assert_run pcmanfm "$(pwd)/$LABDIR/file.txt" |