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

Discussion in 'Python' started by bolega, Jan 13, 2011.

  1. bolega

    bolega Guest

    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
     
    bolega, Jan 13, 2011
    #1
    1. Advertising

  2. bolega <> 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?

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

    iEYEARECAAYFAk0vcpYACgkQcXJNT6Y4fveF1gCgmw41BZEHgyVzx6gn6HFsS+6W
    zBEAn0OyciTF+qNI5tn/ATiOGROw2dW5
    =ki9L
    -----END PGP SIGNATURE-----
     
    Berthold Höllmann, Jan 13, 2011
    #2
    1. Advertising

  3. bolega

    Chris Rebert Guest

    Re: GURU NEEDED : break a command into several lines and comment eachline

    On Thu, Jan 13, 2011 at 1:18 PM, 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 doesn't seem to have anything whatsoever to do with Python...

    Regards,
    Chris
     
    Chris Rebert, Jan 13, 2011
    #3
  4. Re: GURU NEEDED : break a command into several lines and comment eachline

    On Thu, 13 Jan 2011 16:18:31 -0500, bolega <> 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.)
     
    David W. Hodgins, Jan 13, 2011
    #4
  5. Re: GURU NEEDED : break a command into several lines and commenteachline

    On Thu, 13 Jan 2011 13:49:06 -0800, Chris Rebert wrote:

    > On Thu, Jan 13, 2011 at 1:18 PM, bolega <> wrote:
    >> 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*



    --
    Steven
     
    Steven D'Aprano, Jan 14, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. joe shaboo
    Replies:
    1
    Views:
    545
  2. scad
    Replies:
    23
    Views:
    1,174
    Alf P. Steinbach
    May 17, 2009
  3. Dirk Dre
    Replies:
    6
    Views:
    163
    Robert Schaaf
    May 1, 2009
  4. Ciba LO
    Replies:
    4
    Views:
    186
    Ciba LO
    Jul 8, 2006
  5. Peng Yu
    Replies:
    3
    Views:
    367
    Rainer Weikusat
    May 13, 2013
Loading...

Share This Page