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

T

Todd Burch

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
 
K

Konrad Meyer

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

Quoth Todd Burch:
Todd Burch wrote:
=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 <[email protected]> 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--
 
J

John Joyce

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.
 
T

Todd Burch

John said:
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
 
S

Sebastian Hungerecker

Todd said:
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.
 
S

Shai Rosenfeld

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
 
C

Chad Perrin

Quoth Todd Burch:

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.
 
J

John Joyce

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.
 
K

Konrad Meyer

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

Quoth Chad Perrin:
Quoth Todd Burch:
=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 <[email protected]> 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--
 
K

Konrad Meyer

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

Quoth Konrad Meyer:
Quoth Chad Perrin: =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 <[email protected]> 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 <[email protected]> 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--
 
C

Chad Perrin

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.
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top