Bug 153303

Summary: ls options as root include -a rather than -A
Product: [openSUSE] SUSE Linux 10.1 Reporter: Benjamin Weber <benji>
Component: BasesystemAssignee: Dr. Werner Fink <werner>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Enhancement    
Priority: P5 - None CC: lnussel
Version: Beta 5   
Target Milestone: ---   
Hardware: 64bit   
OS: SuSE Linux 10.1   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Benjamin Weber 2006-02-24 08:47:52 UTC
default $LS_OPTIONS as root are 

-a -N --color=tty -T 0

so ls gets aliased to /bin/ls -a -N --color=tty -T 0

this means . and .. are in directory listings, and -A does not override, this can be annoying when trying to for example copy all files starting with .

perhaps -A would be more sensible than -a by default?
Comment 1 Michael Gross 2006-02-24 13:48:58 UTC
I don't think I get your point here. Why is it a problem to copy all hidden files? If you use the shell's file completion feature it will always include `.' and `..'?
Comment 2 Benjamin Weber 2006-02-24 18:42:41 UTC
copying all hidden files was just one example, but can you think of a good reason /for/ having . and .. in the path, given that it causes problems doing some things. 

for example to copy hidden files one could do:

for i in $(ls -A | grep '^\.'); do cp $i /someplace;

but as ls is aliased to "ls -a" then the above copies everything in the current folder, not just the hidden files, as -a overrides -A.
Comment 3 Michael Gross 2006-02-24 19:04:32 UTC
Benjamin, what has `ls' to do with either of your examples? `ls' is no shell-builtin and `cp' neither?

Your example would work because cp would omit `.' and `..' because they are directories. However changing LS_OPTIONS would change nothing of this behaviour.
Comment 4 Benjamin Weber 2006-02-24 19:18:06 UTC
I'm sorry, if I were doing "cp -r" rather than just cp, then . and .. would not be excluded and everything would be copied.

and changing LS_OPTIONS would change this behaviour, as with -a in LS_OPTIONS gives :

lcars:/home/benji # ls -A | head -n 2
.
..

and without -a in LS_OPTIONS gives:

benji@lcars:~> ls -A | head -n 2
.bash_history
.bashrc
Comment 5 Michael Gross 2006-02-24 23:48:59 UTC
OK I got it. You can use quotes with the command this would not apply the alias including the $LS_OPTIONS.

Werner: Please decide what should be done.
Comment 6 Dr. Werner Fink 2006-02-27 11:14:37 UTC
We do nothing.  Root has to see all files even hidden files. This
is a security requirement and will not changed.
Comment 7 Benjamin Weber 2006-02-27 11:30:27 UTC
I think you are misunderstanding, -A still shows all files even hidden files, it just doesn't show "." and ".." (current and parent directories) If you can think of a good reason for including these in the directory listings by default then I'll understand, but afaik other distros all have -A in options by default, not -a.
Comment 8 Dr. Werner Fink 2006-02-27 13:36:35 UTC
OK, I've changed -a to -A
Comment 9 Ludwig Nussel 2006-04-26 14:06:20 UTC
why did you change l and la? I don't care about plain ls but for l -A sucks. I do want to see the permissions of the directory I am in when using l. l is suse specific anyways and I loved it just the way it used to be.
Comment 10 Dr. Werner Fink 2006-04-27 14:36:51 UTC
Please discuss this with Benjamin Weber.
Comment 11 Ludwig Nussel 2006-04-27 14:42:44 UTC
He didn't even mention l or la, only ls.
Comment 12 Dr. Werner Fink 2006-04-27 15:14:31 UTC
OK -A for ls and -a for l and la