[英]Running shell script with sarge eats my quotes
我正在嘗試使用sarge庫執行 shell 腳本。 我的文件script.sh
有以下內容:
#!/usr/bin/env sh
export LOCAL_PROJECT_ROOT=/path/to/the/dir
inotifywait -mr --exclude '(.git|.idea|node_modules)' \
-e modify,create,delete ${LOCAL_PROJECT_ROOT} --format '%w%f'
我像使用 sarge 一樣運行它:
sarge.run('sh script.sh')
我用htop
看到沒有inotifywait
進程正在運行。 但是,當我使用sh script.sh
直接在 shell 中運行此腳本時,一切都按預期進行。
如果我刪除都包含帶引號的參數的--exclude
和--format
部分,sarge 也可以正常運行。
如果我將腳本重寫為這樣的內容,它也可以與 sarge 一起正常運行:
echo "inotifywait -mr --exclude '(.git|.idea|node_modules)' -e modify,create,delete ${LOCAL_PROJECT_ROOT} --format '%w%f'" | /bin/sh
聽起來像模塊問題。
因為 :
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> 'a' == "a"
True
>>> '%s' %"'a'"
"'a'"
>>> "%s" %'"a"'
'"a"'
>>>
也許 :
#!/usr/bin/env sh
export LOCAL_PROJECT_ROOT=/path/to/the/dir
inotifywait -mr --exclude "(.git|.idea|node_modules)" -e modify,create,delete ${LOCAL_PROJECT_ROOT} --format "%w%f"
\\n
,但你得到了 "\\\\n"inotifywait -mr --exclude '(.git|.idea|node_modules)'
這對 Shell 來說是不夠的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.