Stop shell wildcard character expansion?

后端 未结 4 1512
Happy的楠姐
Happy的楠姐 2020-11-22 11:05

Is there any way for a compiled command-line program to tell bash or csh that it does not want any wildcard characters in its parameters expanded?

For instance, one

4条回答
  •  心在旅途
    2020-11-22 11:10

    The expansion is performed by the shell before your program is run. Your program has no clue as to whether expansion has occurred or not.

       set -o noglob
    

    will switch off expansion in the invoking shell, but you'd have to do that before you invoke your program.

    The alternative is to quote your arguments e.g.

    foo "*"
    

提交回复
热议问题