* GURU NEEDED : break a command into several lines and comment each line
@ 2011-01-13 21:18 bolega
2011-01-14 8:07 ` Oleksandr Gavenko
0 siblings, 1 reply; 9+ messages in thread
From: bolega @ 2011-01-13 21:18 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: gnuist006
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
[not found] <bfd24856-94a9-4b46-b0b7-8c142f5b87f5@z5g2000yqb.googlegroups.com>
@ 2011-01-13 21:45 ` Berthold Höllmann
2011-01-13 22:08 ` David W. Hodgins
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Berthold Höllmann @ 2011-01-13 21:45 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 884 bytes --]
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
-----------
#!/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?
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
[not found] <bfd24856-94a9-4b46-b0b7-8c142f5b87f5@z5g2000yqb.googlegroups.com>
2011-01-13 21:45 ` Berthold Höllmann
@ 2011-01-13 22:08 ` David W. Hodgins
2011-01-13 22:46 ` suvayu ali
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: David W. Hodgins @ 2011-01-13 22:08 UTC (permalink / raw)
To: help-gnu-emacs
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.)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
[not found] <bfd24856-94a9-4b46-b0b7-8c142f5b87f5@z5g2000yqb.googlegroups.com>
2011-01-13 21:45 ` Berthold Höllmann
2011-01-13 22:08 ` David W. Hodgins
@ 2011-01-13 22:46 ` suvayu ali
2011-01-13 22:47 ` Pascal J. Bourguignon
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: suvayu ali @ 2011-01-13 22:46 UTC (permalink / raw)
To: bolega; +Cc: help-gnu-emacs
On Thu, Jan 13, 2011 at 1:18 PM, bolega <gnuist006@gmail.com> wrote:
> 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.
>
I don't think you can, but why post a shell question on the GNU emacs
users list?
> Bolega
>
>
>
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
[not found] <bfd24856-94a9-4b46-b0b7-8c142f5b87f5@z5g2000yqb.googlegroups.com>
` (2 preceding siblings ...)
2011-01-13 22:46 ` suvayu ali
@ 2011-01-13 22:47 ` Pascal J. Bourguignon
2011-01-14 3:12 ` Stefan Monnier
[not found] ` <jwvaaj4b2sb.fsf-monnier+gnu.emacs.help@gnu.org>
5 siblings, 0 replies; 9+ messages in thread
From: Pascal J. Bourguignon @ 2011-01-13 22:47 UTC (permalink / raw)
To: help-gnu-emacs
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
>
> One ought to be able to comment every single switch if desired for
> whatever reason.
Rewrite your script in clisp:
#!/usr/bin/clisp
(ext:shell (format nil "~{~A ~}"
"command" ; comment1
"-sw1" ; comment2
"-sw2" ; comment3
arguments))
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
[not found] <bfd24856-94a9-4b46-b0b7-8c142f5b87f5@z5g2000yqb.googlegroups.com>
` (3 preceding siblings ...)
2011-01-13 22:47 ` Pascal J. Bourguignon
@ 2011-01-14 3:12 ` Stefan Monnier
[not found] ` <jwvaaj4b2sb.fsf-monnier+gnu.emacs.help@gnu.org>
5 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2011-01-14 3:12 UTC (permalink / raw)
To: help-gnu-emacs
> #!/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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
[not found] ` <jwvaaj4b2sb.fsf-monnier+gnu.emacs.help@gnu.org>
@ 2011-01-14 6:28 ` bolega
2011-01-14 17:41 ` Pascal J. Bourguignon
0 siblings, 1 reply; 9+ messages in thread
From: bolega @ 2011-01-14 6:28 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
2011-01-13 21:18 GURU NEEDED : break a command into several lines and comment each line bolega
@ 2011-01-14 8:07 ` Oleksandr Gavenko
0 siblings, 0 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-01-14 8:07 UTC (permalink / raw)
To: help-gnu-emacs
On 13.01.2011 23:18, bolega wrote:
> 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 is offtopic for this list.
But seems POSIX shell do not support inline comments.
You can use such trick (: is NOP command, but `` invoke shell, so
consume CPU resource):
$ printarg -x `: this opt allow x` \
-y `: this opt allow y` \
-z `: this opt allow z`
"printarg"
"-x"
"-y"
"-z"
I put comments before command like (example from Makefile):
# /O1 creates small code
# /Oi- disable generate intrinsic functions (to save exe size)
# /Oy omit frame pointer
# /Gm- disable minimal rebuild
OPTIM_CFLAGS = /O1 /Oi- /Oy /Gm-
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: GURU NEEDED : break a command into several lines and comment each line
2011-01-14 6:28 ` bolega
@ 2011-01-14 17:41 ` Pascal J. Bourguignon
0 siblings, 0 replies; 9+ messages in thread
From: Pascal J. Bourguignon @ 2011-01-14 17:41 UTC (permalink / raw)
To: help-gnu-emacs
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 {}.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-01-14 17:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13 21:18 GURU NEEDED : break a command into several lines and comment each line bolega
2011-01-14 8:07 ` Oleksandr Gavenko
[not found] <bfd24856-94a9-4b46-b0b7-8c142f5b87f5@z5g2000yqb.googlegroups.com>
2011-01-13 21:45 ` Berthold Höllmann
2011-01-13 22:08 ` David W. Hodgins
2011-01-13 22:46 ` suvayu ali
2011-01-13 22:47 ` Pascal J. Bourguignon
2011-01-14 3:12 ` Stefan Monnier
[not found] ` <jwvaaj4b2sb.fsf-monnier+gnu.emacs.help@gnu.org>
2011-01-14 6:28 ` bolega
2011-01-14 17:41 ` Pascal J. Bourguignon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).