Bug 519348 - echo ** list the files in dir
Summary: echo ** list the files in dir
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: 11
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Ondrej Vasik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-08-26 09:38 UTC by yayati
Modified: 2009-08-26 10:17 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-08-26 09:59:20 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description yayati 2009-08-26 09:38:37 UTC
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 09:58:24 UTC
Not security.

Comment 2 Ondrej Vasik 2009-08-26 09:59:20 UTC
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 10:03:51 UTC
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 10:17:46 UTC
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.