Strange behavior of argv when passing string containing “!!!!”

前端 未结 3 938
[愿得一人]
[愿得一人] 2020-12-30 20:40

I have written a small program that takes some input parameters from *argv[] and prints them. In almost all use cases my code works perfectly fine. A problem on

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 20:53

    In addition to the supplied answers, you should remember that echo is your shell friend. If you prefix your command with "echo ", you will see what shell is actually sending to your script.

    echo ./program -m "Hello, world!!!!"
    

    This would have showed you some strangeness and might have helped steer you in the right direction.

提交回复
热议问题