"myscript.rb " - there's a blank in my name!

Discussion in 'Ruby' started by Todd Burch, Sep 24, 2007.

  1. Todd Burch

    Todd Burch Guest

    On a Mac - Tiger 10.4.10.

    I wrote a ruby script in TextWrangler (2.2.1) and saved it. I
    inadvertently hit the space bar after the ".rb" and saved it. Then, not
    realizing a blank got added to the name, I attempted to run it and it
    could not be found. After messing with it, I realized the blank was
    saved as the third character after the "b" in .rb.

    Running

    ruby myscript.rb

    failed.

    Running

    ruby "myscript.rb "

    worked. Is this a Mac thing? I've nevver know a blank character at the
    end of a file name to be significant.

    Todd
    --
    Posted via http://www.ruby-forum.com/.
     
    Todd Burch, Sep 24, 2007
    #1
    1. Advertising

  2. Todd Burch

    Todd Burch Guest

    Todd Burch wrote:

    > I've nevver know a blank character at the
    > end of a file name to be significant.
    >

    "never known" ... sorry.
    --
    Posted via http://www.ruby-forum.com/.
     
    Todd Burch, Sep 24, 2007
    #2
    1. Advertising

  3. Todd Burch

    Konrad Meyer Guest

    --nextPart1217562.N1n0rbi7R3
    Content-Type: text/plain;
    charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Quoth Todd Burch:
    > Todd Burch wrote:
    >=20
    > > I've nevver know a blank character at the
    > > end of a file name to be significant.
    > >=20

    > "never known" ... sorry.


    Yes, on *nix systems this is significant (probably windows too, I'm just
    unfamiliar with it). You can also do "ruby myprog.rb\ " to escape the space.

    HTH,
    =2D-=20
    Konrad Meyer <> http://konrad.sobertillnoon.com/

    --nextPart1217562.N1n0rbi7R3
    Content-Type: application/pgp-signature; name=signature.asc
    Content-Description: This is a digitally signed message part.

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)

    iD8DBQBG91NiCHB0oCiR2cwRAjFQAKCD3DVA10tbrtI6nVJ/mW61CcVDlQCfUwuL
    DwT2jb5EbPlZnve//XAgi7Y=
    =IDXt
    -----END PGP SIGNATURE-----

    --nextPart1217562.N1n0rbi7R3--
     
    Konrad Meyer, Sep 24, 2007
    #3
  4. Todd Burch

    John Joyce Guest

    Mac OS (before X even) respects spaces in file names. At the
    beginning and at the end.
    It's not the only *nix that does.

    On Sep 24, 2007, at 12:54 AM, Todd Burch wrote:

    > On a Mac - Tiger 10.4.10.
    >
    > I wrote a ruby script in TextWrangler (2.2.1) and saved it. I
    > inadvertently hit the space bar after the ".rb" and saved it.
    > Then, not
    > realizing a blank got added to the name, I attempted to run it and it
    > could not be found. After messing with it, I realized the blank was
    > saved as the third character after the "b" in .rb.
    >
    > Running
    >
    > ruby myscript.rb
    >
    > failed.
    >
    > Running
    >
    > ruby "myscript.rb "
    >
    > worked. Is this a Mac thing? I've nevver know a blank character
    > at the
    > end of a file name to be significant.
    >
    > Todd
    > --
    > Posted via http://www.ruby-forum.com/.
    >
     
    John Joyce, Sep 24, 2007
    #4
  5. Todd Burch

    Todd Burch Guest

    John Joyce wrote:
    > Mac OS (before X even) respects spaces in file names. At the
    > beginning and at the end.
    > It's not the only *nix that does.


    Wow. Who would have thunk. I gotta watch that fat thumb from now on.

    Thanks guys.

    Todd
    --
    Posted via http://www.ruby-forum.com/.
     
    Todd Burch, Sep 24, 2007
    #5
  6. Todd Burch wrote:
    > After messing with it, I realized the blank was
    > saved as the third character after the "b" in .rb.
    >
    > Running
    > ruby myscript.rb
    > failed.
    >
    > Running
    > ruby "myscript.rb "
    > worked.


    You know you should really use tab completion. It saves a lot of typing and in
    cases where the filename isn't exactly what you think it is it helps you find
    the problem a lot faster.


    --
    Jabber:
    ICQ: 205544826
     
    Sebastian Hungerecker, Sep 24, 2007
    #6
  7. > You know you should really use tab completion. It saves a lot of typing
    > and in
    > cases where the filename isn't exactly what you think it is it helps you
    > find
    > the problem a lot faster.


    here here on the tab suggestion; i personally couldn't work without it
    --
    Posted via http://www.ruby-forum.com/.
     
    Shai Rosenfeld, Sep 24, 2007
    #7
  8. Todd Burch

    Chad Perrin Guest

    On Mon, Sep 24, 2007 at 03:04:27PM +0900, Konrad Meyer wrote:
    > Quoth Todd Burch:
    > > Todd Burch wrote:
    > >
    > > > I've nevver know a blank character at the
    > > > end of a file name to be significant.
    > > >

    > > "never known" ... sorry.

    >
    > Yes, on *nix systems this is significant (probably windows too, I'm just
    > unfamiliar with it). You can also do "ruby myprog.rb\ " to escape the space.


    If I'm not mistaken, MacOS X uses bash as its default shell. That would
    mean you don't actually need to escape the space if you use quotes:

    $ ruby "myprog.rb "

    The same is true of (t)csh:

    > ruby 'myprog.rb '


    In either shell, whether you use single or double quotes doesn't matter,
    and escaping the space (without quotes) also works.

    Whether or not the space is significant when first naming the file
    depends on how you name it. I believe that is true on MS Windows as well
    as systems such as MacOS X, various Linux distributions, SysV and BSD
    Unix systems, and so on -- though I don't have an MS Windows machine in
    front of me to test it. An extra space after a filename shouldn't
    produce a space character in the the filename itself when entered at a
    command line shell, but will probably do so with certain GUI-oriented
    means of naming files.

    --
    CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    McCloctnick the Lucid: "The first rule of magic is simple. Don't waste your
    time waving your hands and hopping when a rock or a club will do."
     
    Chad Perrin, Sep 24, 2007
    #8
  9. Todd Burch

    John Joyce Guest

    yes, OS X 10.4 and upcoming 10.5 all use Bash as the default shell.
    You can of course change that to any of the others that ship with it.
    Earlier versions used Tcsh as default, but shipped with Bash and a
    few others.
     
    John Joyce, Sep 24, 2007
    #9
  10. Todd Burch

    Konrad Meyer Guest

    --nextPart1918760.eQEIE7I9nh
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Quoth Chad Perrin:
    > On Mon, Sep 24, 2007 at 03:04:27PM +0900, Konrad Meyer wrote:
    > > Quoth Todd Burch:
    > > > Todd Burch wrote:
    > > >=20
    > > > > I've nevver know a blank character at the
    > > > > end of a file name to be significant.
    > > > >=20
    > > > "never known" ... sorry.

    > >=20
    > > Yes, on *nix systems this is significant (probably windows too, I'm just
    > > unfamiliar with it). You can also do "ruby myprog.rb\ " to escape the=20

    space.
    >=20
    > If I'm not mistaken, MacOS X uses bash as its default shell. That would
    > mean you don't actually need to escape the space if you use quotes:
    >=20
    > $ ruby "myprog.rb "
    >=20
    > The same is true of (t)csh:
    >=20
    > > ruby 'myprog.rb '

    >=20
    > In either shell, whether you use single or double quotes doesn't matter,
    > and escaping the space (without quotes) also works.
    >=20
    > Whether or not the space is significant when first naming the file
    > depends on how you name it. I believe that is true on MS Windows as well
    > as systems such as MacOS X, various Linux distributions, SysV and BSD
    > Unix systems, and so on -- though I don't have an MS Windows machine in
    > front of me to test it. An extra space after a filename shouldn't
    > produce a space character in the the filename itself when entered at a
    > command line shell, but will probably do so with certain GUI-oriented
    > means of naming files.
    >=20
    > --=20
    > CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    > McCloctnick the Lucid: "The first rule of magic is simple. Don't waste yo=

    ur
    > time waving your hands and hopping when a rock or a club will do."


    The quotes were for quoting the entire command, not the argument.
    Escaping works without quotes. Tab-completion will should you the escaped
    form (sans quotes).

    Regards,
    =2D-=20
    Konrad Meyer <> http://konrad.sobertillnoon.com/

    --nextPart1918760.eQEIE7I9nh
    Content-Type: application/pgp-signature; name=signature.asc
    Content-Description: This is a digitally signed message part.

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)

    iD8DBQBG+AS7CHB0oCiR2cwRAgbQAJ0fQ6qrhps6OoR3aFLLAyLmXwVo1QCfYRE4
    rhbm7g3WzQmBqq198zh6Jzo=
    =2aCD
    -----END PGP SIGNATURE-----

    --nextPart1918760.eQEIE7I9nh--
     
    Konrad Meyer, Sep 24, 2007
    #10
  11. Todd Burch

    Konrad Meyer Guest

    --nextPart2117347.5UumpdC000
    Content-Type: text/plain;
    charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Quoth Konrad Meyer:
    > Quoth Chad Perrin:
    > > On Mon, Sep 24, 2007 at 03:04:27PM +0900, Konrad Meyer wrote:
    > > > Quoth Todd Burch:
    > > > > Todd Burch wrote:
    > > > >=20
    > > > > > I've nevver know a blank character at the
    > > > > > end of a file name to be significant.
    > > > > >=20
    > > > > "never known" ... sorry.
    > > >=20
    > > > Yes, on *nix systems this is significant (probably windows too, I'm j=

    ust
    > > > unfamiliar with it). You can also do "ruby myprog.rb\ " to escape the=

    =20
    > space.
    > >=20
    > > If I'm not mistaken, MacOS X uses bash as its default shell. That would
    > > mean you don't actually need to escape the space if you use quotes:
    > >=20
    > > $ ruby "myprog.rb "
    > >=20
    > > The same is true of (t)csh:
    > >=20
    > > > ruby 'myprog.rb '

    > >=20
    > > In either shell, whether you use single or double quotes doesn't matter,
    > > and escaping the space (without quotes) also works.
    > >=20
    > > Whether or not the space is significant when first naming the file
    > > depends on how you name it. I believe that is true on MS Windows as we=

    ll
    > > as systems such as MacOS X, various Linux distributions, SysV and BSD
    > > Unix systems, and so on -- though I don't have an MS Windows machine in
    > > front of me to test it. An extra space after a filename shouldn't
    > > produce a space character in the the filename itself when entered at a
    > > command line shell, but will probably do so with certain GUI-oriented
    > > means of naming files.
    > >=20
    > > --=20
    > > CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    > > McCloctnick the Lucid: "The first rule of magic is simple. Don't waste=

    =20
    your
    > > time waving your hands and hopping when a rock or a club will do."

    >=20
    > The quotes were for quoting the entire command, not the argument.
    > Escaping works without quotes. Tab-completion will should you the escaped
    > form (sans quotes).
    >=20
    > Regards,
    > --=20
    > Konrad Meyer <> http://konrad.sobertillnoon.com/


    Er, my bad. Tab-completion should *also* give you the escaped form (sans
    quotes). My English translator must be broken today.

    =2D-=20
    Konrad Meyer <> http://konrad.sobertillnoon.com/

    --nextPart2117347.5UumpdC000
    Content-Type: application/pgp-signature; name=signature.asc
    Content-Description: This is a digitally signed message part.

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)

    iD8DBQBG+AucCHB0oCiR2cwRAofBAJ9eAkl+Qdn57pYHQI2ZzdFbFA90+QCg1Rty
    GctitvfPrwahXPAi8nO7kVY=
    =h707
    -----END PGP SIGNATURE-----

    --nextPart2117347.5UumpdC000--
     
    Konrad Meyer, Sep 24, 2007
    #11
  12. Todd Burch

    Chad Perrin Guest

    On Tue, Sep 25, 2007 at 03:41:26AM +0900, Konrad Meyer wrote:
    >
    > The quotes were for quoting the entire command, not the argument.
    > Escaping works without quotes. Tab-completion will should you the escaped
    > form (sans quotes).


    My intent was not to imply that you recommended using an escape character
    with the argument in quotes. I correctly understood your intent, but
    apparently was not clear enough in mine: to explain that quotes provide
    an additional means of dealing with it, separate from escaping the space
    character.

    --
    CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    Amazon.com interview candidate: "When C++ is your hammer, everything starts
    to look like your thumb."
     
    Chad Perrin, Sep 24, 2007
    #12
  13. Todd Burch

    Ron Fox Guest

    From a shell command:

    mv "myscript.rb " myscript.rb

    Bye bye blank.

    RF

    Todd Burch wrote:
    > On a Mac - Tiger 10.4.10.
    >
    > I wrote a ruby script in TextWrangler (2.2.1) and saved it. I
    > inadvertently hit the space bar after the ".rb" and saved it. Then, not
    > realizing a blank got added to the name, I attempted to run it and it
    > could not be found. After messing with it, I realized the blank was
    > saved as the third character after the "b" in .rb.
    >
    > Running
    >
    > ruby myscript.rb
    >
    > failed.
    >
    > Running
    >
    > ruby "myscript.rb "
    >
    > worked. Is this a Mac thing? I've nevver know a blank character at the
    > end of a file name to be significant.
    >
    > Todd
     
    Ron Fox, Sep 25, 2007
    #13
    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. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    876
    Roedy Green
    Jan 2, 2006
  2. ding feng
    Replies:
    2
    Views:
    2,876
    ding feng
    Jun 25, 2003
  3. Replies:
    2
    Views:
    279
    Thomas J. Gritzan
    Feb 13, 2007
  4. tmallen
    Replies:
    19
    Views:
    562
    Miles
    Nov 5, 2008
  5. Nathan O.
    Replies:
    10
    Views:
    213
    Nathan Olberding
    Mar 9, 2006
Loading...

Share This Page