0

I encounter an error with BASHs tab-completion with a variable being part of a filename or path. The variable points to a certain path and that variable gets generated during boot time. Due to an scripting error or maybe intentional it has a double "//" in it but usually such double / is of no concern.

Lets assume the variable is named $LIVESOURCE and points to /mnt/sda1/DIRECTORY1//directory2 - it has no ending "/", but it always refers to a folder, not a file. In this path there are other files and folders I want to access, either read files or copy files into folder(s).

So I do the following: I type e.g.

$ ls $LIVESOURCE/rootcopy/home/username/.moonchild\ productions/pale\ moon/

and while the cursor is at the end of the typed line I press [TAB] or [TAB][TAB] to see which files and folders are there to be found in the target folder. But for some reason BASH changes the above after I press [TAB] once into

$ ls \$LIVESOURCE/rootcopy/home/username/.moonchild\ productions/pale\ moon/

Which of course results in an error. Why is BASH doing that?

When I do type the following

$ cp /usr/local/bin/dummyfile $LIVESOURCE/rootcopy/usr/local/bin/

and press [TAB] BASH is not changing the $LIVESOURCE part into \$LIVESOURCE - but here $LIVESOURCE is not at the beginning of the CLI input. Instead BASH lists the files and folders that are to be found in the target directory - as it should.

My BASH is V5.0.11(1) x86-64 Slackware.

(I did search for "bash tab-completion variable" but found no appropriate topic that would answer my question)

Rava
  • 53
  • 7

0 Answers0