[Bug 799241] New: ls command fails when IFS is set to exclude space character, because of the default alias (fix provided)
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c0 Summary: ls command fails when IFS is set to exclude space character, because of the default alias (fix provided) Classification: openSUSE Product: openSUSE 12.2 Version: Final Platform: All OS/Version: openSUSE 12.2 Status: NEW Severity: Minor Priority: P5 - None Component: Other AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: peter.maloney@brockmann-consult.de QAContact: qa-bugs@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0 ls command fails when IFS is set to exclude space character, because of the default alias. It has an error message: ls: invalid option -- ' ' Here is the fix (using an array instead of a string, so the IFS variable is only used when setting the array, not every time ls is run): IFS=' ' LS_OPTIONS2=($LS_OPTIONS) alias ls='ls ${LS_OPTIONS2[@]}' I have this in my ~/.bash_profile now, but if this was made the default ls alias, then it would work by default. Other distros (eg. debian and Ubuntu) have a different alias (alias ls='ls --color=auto'), and don't have this problem. Reproducible: Always Steps to Reproduce: The expected output: $ ls device.map e2fs_stage1_5 ffs_stage1_5 jfs_stage1_5 menu.lst.old reiserfs_stage1_5 stage2 ufs2_stage1_5 xfs_stage1_5 device.map.old fat_stage1_5 iso9660_stage1_5 menu.lst minix_stage1_5 stage1 stage2.old vstafs_stage1_5 The problem: $ IFS=$'\n' $ ls ls: invalid option -- ' ' Try `ls --help' for more information. The fix: $ IFS=' ' LS_OPTIONS2=($LS_OPTIONS) $ alias ls='ls ${LS_OPTIONS2[@]}' $ ls device.map e2fs_stage1_5 ffs_stage1_5 jfs_stage1_5 menu.lst.old reiserfs_stage1_5 stage2 ufs2_stage1_5 xfs_stage1_5 device.map.old fat_stage1_5 iso9660_stage1_5 menu.lst minix_stage1_5 stage1 stage2.old vstafs_stage1_5 Actual Results: $ ls ls: invalid option -- ' ' Try `ls --help' for more information. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c Du Weihua <whdu@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |whdu@suse.com AssignedTo|bnc-team-screening@forge.pr |werner@suse.com |ovo.novell.com | -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c1 Dr. Werner Fink <werner@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO InfoProvider| |peter.maloney@brockmann-con | |sult.de --- Comment #1 from Dr. Werner Fink <werner@suse.com> 2013-03-01 10:54:55 UTC --- Hmmm ... there is a reason *why* a variable was choosen for this. This enables the user to change this variable without sourcing the /etc/profile.d/ls.bash again. How you want to get this feature back with your apporach? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c2 --- Comment #2 from Peter Maloney <peter.maloney@brockmann-consult.de> 2013-03-01 11:01:48 UTC --- Well, I didn't know that, but it is still a variable... it can still be changed, but as an array (which means only adding () around it), even if you don't use the "IFS=' '" in there which I only provided to be more technically right even though it's the same effect. eg. user types in this (strange example... just for something that needs a space because there is no short option for --full-time) ~/tmp/test1$ LS_OPTIONS2=(-al --full-time) ~/tmp/test1$ ls total 24 drwxr-xr-x 4 peter users 4096 2012-09-13 17:12:34.847347528 +0200 . drwxr-xr-x 45 peter vboxusers 12288 2013-02-27 14:10:37.202287674 +0100 .. drwxr-xr-x 2 peter users 4096 2012-09-13 15:40:13.266210947 +0200 test2 drwxr-xr-x 2 peter users 4096 2012-09-13 15:40:08.618053315 +0200 test3 prw-r--r-- 1 peter users 0 2012-09-13 17:12:37.455228460 +0200 testpipe -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c3 --- Comment #3 from Dr. Werner Fink <werner@suse.com> 2013-03-01 11:07:11 UTC --- Hmm ... and what about zsh, ksh, dash, ash ... does this work for all bourne shells? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c4 --- Comment #4 from Peter Maloney <peter.maloney@brockmann-consult.de> 2013-03-01 11:47:28 UTC --- Sorry, I don't know the other shells. My solution went in my .bash_profile. I tried it with zsh and ksh, with same results. Both work fine. Here's zsh. peter@peter:~> unset LS_OPTIONS2 peter@peter:~> unset LS_OPTIONS peter@peter:~> alias ls='ls ${LS_OPTIONS2[@]}' peter@peter:~> LS_OPTIONS2=(-al --full-time) peter@peter:~> IFS=$'\n' peter@peter:~> cd ~/tmp/test1 peter@peter:~/tmp/test1> ls total 24 drwxr-xr-x 4 peter users 4096 2012-09-13 17:12:34.847347528 +0200 . drwxr-xr-x 45 peter vboxusers 12288 2013-02-27 14:10:37.202287674 +0100 .. drwxr-xr-x 2 peter users 4096 2012-09-13 15:40:13.266210947 +0200 test2 drwxr-xr-x 2 peter users 4096 2012-09-13 15:40:08.618053315 +0200 test3 prw-r--r-- 1 peter users 0 2012-09-13 17:12:37.455228460 +0200 testpipe I installed dash (never heard of it), and it doesn't like the () arrays. And I read that dash has no arrays. So what do you suggest? Is it clean to implement it with an if/case? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c5 Peter Maloney <peter.maloney@brockmann-consult.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW InfoProvider|peter.maloney@brockmann-con | |sult.de | --- Comment #5 from Peter Maloney <peter.maloney@brockmann-consult.de> 2013-04-23 07:47:01 UTC --- Here is another version of my fix with no arrays, so it works in dash (as well as bash, zsh, and ksh). alias ls="IFS=' ' ls $(echo $LS_OPTIONS)" For bash, the array one's only advantage I see is the args can have spaces in them, as long as the array was set with quotes. But since spaces would have already been a problem in the SUSE version (assuming this problem is relevant to an ls alias rather than just a general problem in bash), this one should make you happy. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c6 --- Comment #6 from Dr. Werner Fink <werner@suse.com> 2013-04-23 15:02:15 UTC --- (In reply to comment #5) Hmmm ... bash-4-2> alias | grep IFS alias ls='IFS='\'' '\'' ls -N --color=tty -T 0' die Variable $LS_OPTIONS wird expandiert -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c7 Dr. Werner Fink <werner@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #7 from Dr. Werner Fink <werner@suse.com> 2013-04-23 15:55:26 UTC --- Just fixed this for factory -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c8 --- Comment #8 from Bernhard Wiedemann <bwiedemann@suse.com> 2013-04-23 18:00:14 CEST --- This is an autogenerated message for OBS integration: This bug (799241) was mentioned in https://build.opensuse.org/request/show/173069 Factory / aaa_base -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=799241 https://bugzilla.novell.com/show_bug.cgi?id=799241#c9 --- Comment #9 from Bernhard Wiedemann <bwiedemann@suse.com> 2013-04-23 19:00:30 CEST --- This is an autogenerated message for OBS integration: This bug (799241) was mentioned in https://build.opensuse.org/request/show/173072 Factory / aaa_base -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com