Preserving quotes in bash function parameters

后端 未结 8 792
天涯浪人
天涯浪人 2020-12-05 05:13

What I\'d like to do is take, as an input to a function, a line that may include quotes (single or double) and echo that line exactly as it was provided to the function. For

8条回答
  •  不思量自难忘°
    2020-12-05 05:34

    doit echo "'single quote $VAR'"
    doit echo '"double quote $VAR"'
    

    Both will work.

    bash will only strip the outside set of quotes when entering the function.

提交回复
热议问题