Bug 519348 - echo ** list the files in dir
echo ** list the files in dir
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
11
All Linux
low Severity medium
: ---
: ---
Assigned To: Ondrej Vasik
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-08-26 05:38 EDT by yayati
Modified: 2009-08-26 06:17 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-08-26 05:59:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description yayati 2009-08-26 05:38:37 EDT
Description of problem: 

`line="**";echo $line`

produces the out put of `ls -d` that is the file names in the directory
a double astrix (**) any where in a string also produces the same result

Also tried with "env echo"

--
[yayati@mini filesplit]$ line='**';env echo $line
deleme.txt new1.log new.log Parse_file_writeup.doc Parse_file_writeup_query.doc Parse_file_writeup_query.zip RC40A.BU1.XFB10.MARISVO.C7501V00 record_parse.sh records samdata.txt SmallSampleDataFile.txt t1.sh test.sh
[yayati@mini filesplit]$ 
--


Version-Release number of selected component (if applicable):
coreutils-7.2-1.fc11.i586

How reproducible:
line='**';env echo $line

Steps to Reproduce:
1.line='**';env echo $line
2.
3.
  
Actual results:
deleme.txt new1.log new.log Parse_file_writeup.doc Parse_file_writeup_query.doc Parse_file_writeup_query.zip RC40A.BU1.XFB10.MARISVO.C7501V00 record_parse.sh records samdata.txt SmallSampleDataFile.txt t1.sh test.sh

Expected results:
**

Additional info:
why does echo interpret ** as files in the dir?
Comment 1 Tomas Hoger 2009-08-26 05:58:24 EDT
Not security.
Comment 2 Ondrej Vasik 2009-08-26 05:59:20 EDT
Thanks for report, but what you see is just shell expansion of argument. Additionally, usually you don't use coreutils utility `echo` but shell builtin echo (I assume you use bash). If you want to prevent shell expansion, use double quotes around the variables (common practice in shell scripts). That's NOTABUG, not security, just expected behaviour, closing.
Comment 3 Tomas Hoger 2009-08-26 06:03:51 EDT
Also not a bug imo.  * is shell meta character, that "matches any string, including the empty string" (glob(7)).  It is expected that something like this:

  echo *

is expanded by shell to:

  echo [list of all files in current directory]

before command in question (echo here) is run.  You can use quotes to prevent expansion.
Comment 4 yayati 2009-08-26 06:17:46 EDT
Thanks all of you, I apologise for wasting your valuable time.

Regards.

Note You need to log in before you can comment on or make changes to this bug.