path_option.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env sh
  2. # Before running the script make sure a flameshot daemon with a matching version
  3. # is running
  4. # The first argument to this script is a path to the flameshot executable
  5. [ -n "$1" ] && flameshot="$1" || flameshot='flameshot'
  6. # TODO Before proper stderr logging is implemented, you will have to look at the
  7. # system notifications
  8. rm -rf /tmp/flameshot_path_test 2>/dev/null
  9. mkdir -p /tmp/flameshot_path_test
  10. cd /tmp/flameshot_path_test
  11. echo ">> Nonexistent directory. This command should give an invalid path error."
  12. "$flameshot" screen -p blah/blah
  13. sleep 2
  14. echo ">> The output file is specified relative to PWD"
  15. "$flameshot" screen -p relative.png
  16. sleep 2
  17. echo ">> Absolute paths work too"
  18. "$flameshot" screen -p /tmp/flameshot_path_test/absolute.png
  19. sleep 2
  20. mkdir subdir
  21. echo ">> Redundancy in the path will be removed"
  22. "$flameshot" screen -p /tmp/flameshot_path_test/subdir/..///redundancy_removed.png
  23. sleep 2
  24. echo ">> If the destination is a directory, the file name is generated from strf from the config"
  25. "$flameshot" screen -p ./
  26. sleep 2
  27. echo ">> If the output file has no suffix, it will be added (png)"
  28. "$flameshot" screen -p /tmp/flameshot_path_test/without_suffix
  29. sleep 2
  30. echo ">> Other suffixes are supported, and the image format will match it"
  31. "$flameshot" screen -p /tmp/flameshot_path_test/jpg_suffix.jpg
  32. sleep 2
  33. echo ">> If the destination path exists, it will have _NUM appended to the base name"
  34. "$flameshot" screen -p /tmp/flameshot_path_test/absolute.png
  35. sleep 2
  36. echo ">> Same thing again but without specifying a suffix"
  37. "$flameshot" screen -p /tmp/flameshot_path_test/absolute
  38. sleep 2