Skip to main content
13 events
when toggle format what by license comment
Aug 17, 2020 at 20:23 comment added G-Man Says 'Reinstate Monica' I don’t understand what you’re saying about find options.  -mtime -111 -mtime -222 is equivalent to -mtime -111 (the more restrictive one).  -mtime -42 -mtime +56 gives you a range (six to eight weeks).  OK, alias chaining could result in -print -print, and I’ll admit that the fact that that prints twice is not as elegant as things like ls -l -l.
Aug 17, 2020 at 18:56 history edited John1024 CC BY-SA 4.0
added 2 characters in body
Aug 17, 2020 at 18:44 comment added John1024 @schily Thanks for that info. I added the ksh history to the answer.
Aug 17, 2020 at 18:44 history edited John1024 CC BY-SA 4.0
added 398 characters in body
Aug 17, 2020 at 18:33 comment added John1024 @Chris Most command-line utilities (oddities like rsync & find are exceptions) handle repeated options gracefully. If two options contradict each other (such as ls' -U and -t options), the later specified option overrides the one specified first. This makes aliases work sensibly.
Aug 17, 2020 at 7:52 comment added schily You are correct, but the concept you are describing is not from bash but from ksh.
Aug 17, 2020 at 6:05 comment added Chris Thanks for clarifying the shell behaviour John. I also expected ls to whinge about receiving multiple sets of arguments as in ls -Flatr --color=always -FlatrR --color=always, but it doesn't seem to be concerned and just crunches away (more man'ing from the looks of it...)...so, with curiosity satisfied, I can go back to some slightly more sane alias definitions :-)
Aug 17, 2020 at 5:36 comment added John1024 @Chris That is because, when running lscR, it is ls, not lsc, that bash refuses to expand the second time. Since a real command named ls exists, bash runs it. I added a more detailed explanation of this to the answer.
Aug 17, 2020 at 5:33 history edited John1024 CC BY-SA 4.0
added 439 characters in body
Aug 17, 2020 at 5:08 comment added Chris Further question in light of your explanation, how come when I call lscR it doesn't expand the ls call in that alias (since there is an alias ls='lsc') and then end up running the lsc alias instead? it definitely runs the command aliased to lscR (verifiable because it uses the recursive ls, not single level ls as used in the ls and lsc aliases)....EDIT: I think the explanation here is tied in with muru's answer below actually.
Aug 17, 2020 at 5:02 comment added Chris Ah, that is so obvious now you mention it! Somehow in my head I must have been imagining it being processed as a top to bottom flow, so it didn't occur to me that there was a recursive call 'back up' to the ls alias above. Thanks for pointing that out!
Aug 17, 2020 at 4:59 vote accept Chris
Aug 17, 2020 at 4:58 history answered John1024 CC BY-SA 4.0