LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 12-10-2017, 09:34 AM   #16
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51

Quote:
Originally Posted by rknichols View Post
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.
 
Old 12-10-2017, 09:38 AM   #17
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by pan64 View Post
if you want to understand bash probably you can use set -x:
Code:
user@host:/tmp$ touch *asd*    # << this is what you entered
+ touch '*asd*'                # << this is what was execcuted after evaluation of command line
I did not know about that option. I will examine its consequences later. Hope you have seen my new-question post.
 
Old 12-10-2017, 10:02 AM   #18
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
Originally Posted by dedec0 View Post
Code:
$  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.
Code:
user@host:/tmp/a$ touch "9asd*lkj"
user@host:/tmp/a$ touch "9asda*lkj"
user@host:/tmp/a$ set -x
user@host:/tmp/a$ rm 9asd*lkj
+ rm '9asda*lkj' '9asd*lkj'
Quote:
Originally Posted by dedec0 View Post
Do you consider this a bug in Bash? I do, but I would like to see more opinions in this.
No, this is how it really should work.
 
Old 12-10-2017, 10:26 AM   #19
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by pan64 View Post
This is the real story: that expression is expanded to all the files matching.
Code:
user@host:/tmp/a$ touch "9asd*lkj"
user@host:/tmp/a$ touch "9asda*lkj"
user@host:/tmp/a$ set -x
user@host:/tmp/a$ rm 9asd*lkj
+ rm '9asda*lkj' '9asd*lkj'

No, this is how it really should work.
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. Not a literal * in it, being one word only!

/-:
 
Old 12-10-2017, 10:54 AM   #20
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
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 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...)
 
Old 12-10-2017, 11:47 AM   #21
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Exclamation

Quote:
Originally Posted by pan64 View Post
Quote:
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 View Post
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:

Code:
$  touch "9asd*lkj"; ll
9asd*lkj

$  touch "9asda*lkj"; ll
9asda*lkj
9asd*lkj

$  rm 9asd*lkj
removido '9asda*lkj'
removido '9asd*lkj'

$
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:

Code:
ls           lsattr       lscpu        lsipc        lsmod        
lspci        lsusb        ls1          lsblk        lsd
lsram        lslocks      lsns         lspgpot      lsof              
lsar         lsb_release  lsinitramfs  lslogins

Last edited by dedec0; 12-10-2017 at 11:50 AM.
 
Old 12-10-2017, 12:01 PM   #22
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
Old 12-10-2017, 12:32 PM   #23
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
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.
 
Old 12-11-2017, 07:38 AM   #24
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
@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 View Post
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.
 
Old 12-11-2017, 08:22 AM   #25
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
Originally Posted by dedec0 View Post
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.
 
1 members found this post helpful.
Old 12-11-2017, 10:20 AM   #26
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by pan64 View Post
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.
Ok. Thank you for explaining it a bit more.
 
  


Reply

Tags
bash



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to display alias commands and un-alias any less than 12 characters bani Linux - Newbie 5 01-19-2014 12:34 PM
bash: command works at command line, but not via an alias porphyry5 Programming 3 03-17-2012 02:48 PM
Using an alias inside a function in bash martindl Linux - Newbie 1 06-08-2011 11:55 PM
Using shortcuts/alias inside a Linux Bash Command pratap.iisc Linux - General 3 01-30-2010 04:52 AM
Creating mult command alias in BASH labob Linux - Newbie 1 11-18-2004 07:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration