View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008084 | Kali Linux | [All Projects] General Bug | public | 2022-12-04 10:58 | 2022-12-04 19:36 |
Reporter | m4tt | Assigned To | daniruiz | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | suspended | ||
Product Version | 2022.3 | ||||
Target Version | Fixed in Version | ||||
Summary | 0008084: echo command interprets wildcards, when read with the 'cat' command from a file, in a for-loop | ||||
Description | Dear Kali Team, i struggle with a bug in the echo command. The echo command recently started to interpret wildcards, when read from a file, via "cat" in a for loop. I cannot reproduce this bug, outta a for-loop. This seems to happen only in a loop This behavior can be reproduced by me to 100% under similar circumstances. To use a absolute path in echo command "/usr/bin/echo" and "/bin/echo" yielded the same results Screenshots are attached. Greetings and keep on your good work, m4tt | ||||
Steps To Reproduce | As example: echo * ==> list current working directory echo "*" ==> prints a '*' var='*'; echo "$var" ==> prints a '*' echo '*' >file; cat file ==> prints a '*' echo '*' >file; a=`cat file`; echo "$a" ==> either print a '*' but echo "*" >b; for i in `cat b`; do echo "$i"; done ==> list current working directory instead of print a '*' same behavior showing other wildcards like '?' Strangely the "while read i; do echo "$i"; done < <textfile_with_wildcard_in> don't show any result. While a: while read i; do echo "$i"; done <<<`cat <textfile_with_wildcard_in>` has the exact desired result, of printing the wildcard | ||||
Additional Information | Linux m0b1 5.18.0-kali7-amd64 0000001 SMP PREEMPT_DYNAMIC Debian 5.18.16-1kali1 (2022-08-31) x86_64 GNU/Linux PRETTY_NAME="Kali GNU/Linux Rolling" NAME="Kali GNU/Linux" VERSION="2022.4" VERSION_ID="2022.4" VERSION_CODENAME="kali-rolling" Package: coreutils Essential: yes Status: install ok installed Priority: required Section: utils Installed-Size: 18062 Maintainer: Michael Stone <mstone@debian.org> Architecture: amd64 Multi-Arch: foreign Version: 9.1-1 | ||||
|
|
|
As Kali is just using the packages from Debian better report it via a bug report mentioned here: https://www.gnu.org/software/coreutils/#mailinglists |
|
This is not a bug, it's running what you are asking for. In your example echo "*" >b; for i in `cat b`; do echo "$i"; done ==> list current working directory instead of print a '*' `cat b` is a command substitution so it gets rewriten as "for i in *", so it iterates all files, that's why it then prints them in the echo inside the loop. If you want the command substitution not to be expanded just add quotes like $ for i in "`cat b`" or use $() as it's more readable and more used nowadays $ for i in "$(cat b)" |
Date Modified | Username | Field | Change |
---|---|---|---|
2022-12-04 10:58 | m4tt | New Issue | |
2022-12-04 10:58 | m4tt | File Added: Screenshot from 2022-12-04 11-12-28.png | |
2022-12-04 10:58 | m4tt | File Added: Screenshot from 2022-12-04 11-46-51.png | |
2022-12-04 14:03 | kali-bugreport | Note Added: 0017139 | |
2022-12-04 19:36 | daniruiz | Note Added: 0017140 | |
2022-12-04 19:36 | daniruiz | Assigned To | => daniruiz |
2022-12-04 19:36 | daniruiz | Status | new => closed |
2022-12-04 19:36 | daniruiz | Resolution | open => suspended |