How can I preserve command line spaces in a linux application?

微笑、不失礼 提交于 2021-02-15 07:46:37

问题


As per this question here, I'm deploying a linux application on some local servers using a shell script that looks like:

   #!/bin/sh
   export LD_LIBRARY_PATH=./libs:$LD_LIBRARY_PATH
   exec ./TheBinary $*

When I run TheBinary without these wrappers (but after having modified LD_LIBRARY_PATH, which I want to do via the script post-deployment), I can preserve spaces in the command line arguments using double quotes ("). But the above script appears to sanitize them away; how can I modify this script to respect spaces in command line arguments that are wrapped in double quotes?


回答1:


#!/bin/bash
export LD_LIBRARY_PATH=./libs:$LD_LIBRARY_PATH
exec ./TheBinary "$@"

I have no real idea whether /bin/sh supports that syntax



来源:https://stackoverflow.com/questions/7731225/how-can-i-preserve-command-line-spaces-in-a-linux-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!