0

In a solution to the question, David Foerster mentions that the following command is incorrectly line-wrapped which introduces line breaks and backspace characters where there should be none:

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Is it possible to show what exactly is he referring in the command?

1
  • I can't reproduce the same behaviour.
    – wjandrea
    Jan 15, 2018 at 23:32

1 Answer 1

1

We can use printf to highlight individual arguments and inspect how the shell tokenizes them. For the command in question vs. the corrected variant in my answer to the linked question (tested in Bash and Dash):

$ printf '"%s"\n' sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
"sudo"
"add-apt-repository"
"deb [arch=amd64] https://download.docker.com/linux/ubuntu        trusty        stable"

and

$ printf '"%s"\n' sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
"sudo"
"add-apt-repository"
"deb [arch=amd64] https://download.docker.com/linux/ubuntu trusty stable"

Oh well, that's not so different. However, this is not what ended up in the repository sources file for the author of the linked question:

Error: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu \ xenial \ stable' invalid

I don't know how that happened but it certainly looks like an issue with the back slashes at the line ends. From where else would they come? Maybe the author actually entered a different command or they used a different shell interpreter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .