Thread View: comp.unix.shell
6 messages
6 total messages
Started by bolega
Thu, 13 Jan 2011 21:18
GURU NEEDED : break a command into several lines and comment each line
Author: bolega
Date: Thu, 13 Jan 2011 21:18
Date: Thu, 13 Jan 2011 21:18
17 lines
1862 bytes
1862 bytes
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
Re: GURU NEEDED : break a command into several lines and comment each line
Author: Berthold Höllmann
Date: Thu, 13 Jan 2011 21:45
Date: Thu, 13 Jan 2011 21:45
59 lines
2539 bytes
2539 bytes
--=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable bolega <gnuist006@gmail.com> writes: > 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=20 =2D---------- #!/bin/bash -xv COMMAND=3Dcommand # comment1 COMMAND=3D$COMMAND -sw1 \ # comment2 COMMAND=3D$COMMAND -sw2 \ # comment3 COMMAND=3D$COMMAND arguments $COMMAND =2D-------- ? Regards=20 Berthold=20 > One ought to be able to comment every single switch if desired for > whatever reason. > > Bolega > > =2D-=20 A: Weil es die Lesbarkeit des Textes verschlechtert. F: Warum ist TOFU so schlimm? A: TOFU F: Was ist das gr=C3=B6=C3=9Fte =C3=84rgernis im Usenet? --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) iEYEARECAAYFAk0vcpYACgkQcXJNT6Y4fveF1gCgmw41BZEHgyVzx6gn6HFsS+6W zBEAn0OyciTF+qNI5tn/ATiOGROw2dW5 =ki9L -----END PGP SIGNATURE----- --=-=-=--
Re: GURU NEEDED : break a command into several lines and comment each line
Author: David W. Hodgins
Date: Thu, 13 Jan 2011 22:08
Date: Thu, 13 Jan 2011 22:08
26 lines
2190 bytes
2190 bytes
On Thu, 13 Jan 2011 16:18:31 -0500, bolega <gnuist006@gmail.com> wrote:
> 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
--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
Re: GURU NEEDED : break a command into several lines and comment each line
Author: Stefan Monnier
Date: Fri, 14 Jan 2011 03:12
Date: Fri, 14 Jan 2011 03:12
19 lines
1718 bytes
1718 bytes
> #!/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. Thanks for the riddle. Here's a solution: command $(: # comment1 ) -sw1 $(: # comment2 ) -sw2 $(: # comment3 ) arguments -- Stefan
Re: GURU NEEDED : break a command into several lines and comment each line
Author: bolega
Date: Fri, 14 Jan 2011 06:28
Date: Fri, 14 Jan 2011 06:28
30 lines
2507 bytes
2507 bytes
On Jan 13, 7:12 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote: > > #!/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. > > Thanks for the riddle. Here's a solution: > > command $(: # comment1 > ) -sw1 $(: # comment2 > ) -sw2 $(: # comment3 > ) arguments > > -- Stefan thanks to all four of you who replied and solved this problem to a large extent, building on each other's ideas. I would have done it by the first method of concatenating or pipes into a sed which replaced end by the next and # can be placed after pipes. the string then fed into a bash. Stefan, whats the purpose of the colon ? it works without colon also. Is it subshell or some environment import ? like the colon which can substitute the #!/bin/bash on the top ? Bolega
Re: GURU NEEDED : break a command into several lines and comment each line
Author: Pascal J. Bourguignon
Date: Fri, 14 Jan 2011 17:41
Date: Fri, 14 Jan 2011 17:41
43 lines
3132 bytes
3132 bytes
bolega <gnuist006@gmail.com> writes:
> On Jan 13, 7:12�pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
>> > #!/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.
>>
>> Thanks for the riddle. �Here's a solution:
>>
>> � command � � � �$(: # comment1
>> � ) � � � �-sw1 �$(: # comment2
>> � ) � � � �-sw2 �$(: # comment3
>> � ) � � � �arguments
>>
>> -- Stefan
>
> thanks to all four of you who replied and solved this problem to a
> large extent, building on each other's ideas.
>
> I would have done it by the first method of concatenating or pipes
> into a sed which replaced end by the next and # can be placed after
> pipes. the string then fed into a bash.
>
> Stefan, whats the purpose of the colon ? it works without colon also.
> Is it subshell or some environment import ? like the colon which can
> substitute the #!/bin/bash on the top ?
The colon is a built-in command equivalent to true.
The syntax specified for $( ... ) (in man bash) is:
$(command)
so a command is expected. The shortest command doing nothing is :.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads