Bash: how to avoid a command inside an alias being used as another alias?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It gets very messy, especially with all the special cases of backslash within double quotes. And, tab completion does not respect wildcards -- all the preceding characters in the word are taken literally.
It is not messy. It is contradictory, and that is bad. See my previous post.
$ touch "9asd*lkj"; ll
9asd*lkj
$ touch "9asda*lkj"; ll
9asda*lkj
9asd*lkj
$ # Before pressing enter for the next command, I tried to expand the argument.
$ rm 9asd*lkj
The argument to rm, as shown, is expanded to one of the two choices it had! It expands to "9asda\*lkj" - without the quotes, plus a space that possibly expected an argument. We normally conclude that the *only* possible file was found, then - at least me. Wouldn't you?
This is the real story: that expression is expanded to all the files matching.
Originally Posted by dedec0 View Post
I expected (and think it is good and reasonable to do so) that a lkj*jkl argument should mean:
All files that start with lkj, have something or nothing in the middle, and ends with jkl.
This part is ok.
Quote:
Originally Posted by pan64
Quote:
Originally Posted by dedec0 View Post
Not a literal * in it, being one word only!
Why not? As you told: have something or nothing in the middle (= including really anything, including even a * - or more...)
Why not? As you told: have something or nothing in the middle (= including really anything, including even a * - or more...)
Because the line rm in the following command set removes two files, not only one:
But if we press tab (instead of enter) after we type the last J, the argument is expanded to one of 2 possible files that exist in the expression given to the expansion routine. That is contradictory! That expansion should not happen! Both should be shown to me as these lines are showed if I press "ls" followed by tab:
As I said in #13, tab completion does not expand wildcards. It takes all the characters literally. If there had been no file with a literal "*" in that character position, tab completion would have failed and given you a "beep" in reponse.
As for use of the words "escaping" vs. "quoting", quoting causes characters within the quotes to be taken literally, removing their special meaning. A backslash removes any special meaning of the character that follows it, and is thus a form of quoting. But, I don't wish to stand in the way of your continuing to find that contradictory or confusing.
yes, tab and * are two different things, do not mix them. they are not working the same way, they have different purposes, different implementations, but also they have some (occasional) similarities.
@rknichols: It has nothing to do with "standing in the way" of nothing. I just do not see that thinking it is good or reasonable. I think there is an issue in this matter.
Quote:
Originally Posted by pan64
yes, tab and * are two different things, do not mix them. they are not working the same way, they have different purposes, different implementations, but also they have some (occasional) similarities.
Mixing them is rare, but I see no problem with the possibility of having one * anywhere in a string to be tested + expanded + results showed (with a second tab). For more than one * in the same string, is will not be possible (or feasible, I do not know if it is) if there is no match for all of them being empty.
I see no problem with the possibility of having one * anywhere in a string to be tested + expanded + results showed (with a second tab)
This is what I tried to explain: you can see no problem, but this is not the way how it was designed/implemented. If you wish that behavior you need to implement that for yourself.
This is what I tried to explain: you can see no problem, but this is not the way how it was designed/implemented. If you wish that behavior you need to implement that for yourself.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.