help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why echo without quotes need to glob the file


From: wang yuhang
Subject: Why echo without quotes need to glob the file
Date: Tue, 13 Dec 2022 20:45:36 +0800

Hello


There are some bad smelling codes in the shell scripts of my company's 
products?? 


just like `echo [--hello]`. As you can see, it echo something without 
quotes. In most cases, it can work normally. But recently, a file 
named 1 happened to appear in the working directory of the shell 
script. This causes' echo [-- hello] 'to output 1.


$ echo [--hello]
[--hello]
$ touch 1
$ echo [--hello]
1


I know the main reason is that my some code is poorly written. from another 
perspective, the builtin command `echo` has nothing to do with file, but it 
still uses regular expressions to glob the file. I don't quite understand 
this behavior??


Could you tell me the reason for the original design ?


Thanks




 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]