Prevent expansion of wildcards in non-quoted python script argument when running in UNIX environment

前端 未结 4 345
囚心锁ツ
囚心锁ツ 2021-01-14 20:26

I have a python script that I\'d like to supply with an argument (usually) containing wildcards, referring to a series of files that I\'d like to do stuff with. Example here

4条回答
  •  旧巷少年郎
    2021-01-14 21:24

    You can disable the expansion using set -f from the command line. (re-enable with set +f).

    As jwodder correctly says though, this happens before the script is run, so the only way I can think of to do this is to wrap it with a shell script that disables expansion temporarily, runs the python script, and re-enables expansion. Preventing UNIX from expanding the list before passing it to python is not possible.

提交回复
热议问题