GURU NEEDED : break a command into several lines and comment each line

B

bolega

Basically, I have spent a few hours experimenting and searching on the
comp.unix.shell

how to break a command with several switches into more than one line
AND to be able to put some comment on each line.

#!/bin/bash -xv

command \ # comment1
-sw1 \ # comment2
-sw2 \ # comment3
arguments

One ought to be able to comment every single switch if desired for
whatever reason.

Bolega
 
B

Berthold Höllmann

bolega said:
Basically, I have spent a few hours experimenting and searching on the
comp.unix.shell

how to break a command with several switches into more than one line
AND to be able to put some comment on each line.

#!/bin/bash -xv

command \ # comment1
-sw1 \ # comment2
-sw2 \ # comment3
arguments

How about

-----------
#!/bin/bash -xv

COMMAND=command # comment1
COMMAND=$COMMAND -sw1 \ # comment2
COMMAND=$COMMAND -sw2 \ # comment3
COMMAND=$COMMAND arguments

$COMMAND
---------
?

Regards
Berthold
One ought to be able to comment every single switch if desired for
whatever reason.

Bolega

--
A: Weil es die Lesbarkeit des Textes verschlechtert.
F: Warum ist TOFU so schlimm?
A: TOFU
F: Was ist das größte Ärgernis im Usenet?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)

iEYEARECAAYFAk0vcpYACgkQcXJNT6Y4fveF1gCgmw41BZEHgyVzx6gn6HFsS+6W
zBEAn0OyciTF+qNI5tn/ATiOGROw2dW5
=ki9L
-----END PGP SIGNATURE-----
 
C

Chris Rebert

Basically, I have spent a few hours experimenting and searching on the
comp.unix.shell

how to break a command with several switches into more than one line
AND to be able to put some comment on each line.

#!/bin/bash -xv

command       \ # comment1
        -sw1 \ # comment2
        -sw2 \ # comment3
        arguments

One ought to be able to comment every single switch if desired for
whatever reason.

This doesn't seem to have anything whatsoever to do with Python...

Regards,
Chris
 
D

David W. Hodgins

how to break a command with several switches into more than one line
AND to be able to put some comment on each line.
command \ # comment1
-sw1 \ # comment2

Not what you want to hear, but that will not work. With the above,
the backslash is being used to escape the following space, rather
then a newline, as is required to continue the line. Even if it
were to work that way, would the next line be considered a continuation
of the command, or of the comment?

Your stuck with

command \
-sw1
# comment1
# comment2

Regards, Dave Hodgins
 
S

Steven D'Aprano

Basically, I have spent a few hours experimenting and searching on the
comp.unix.shell
[...]
This doesn't seem to have anything whatsoever to do with Python...

Well, I launch Python scripts from the shell, so there's your connection.

*wink*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,007
Messages
2,570,266
Members
46,865
Latest member
AveryHamme

Latest Threads

Top