Bug 519348

Summary: echo ** list the files in dir
Product: [Fedora] Fedora Reporter: yayati <jobsyayati>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: thoger
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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: ---

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.