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

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

Todd B. wrote:

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

“never known” … sorry.

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.

Quoth Todd B.:

Todd B. 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.

HTH,

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

Todd B. 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.

On Mon, Sep 24, 2007 at 03:04:27PM +0900, Konrad M. wrote:

Quoth Todd B.:

Todd B. 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.

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

Quoth Chad P.:

unfamiliar with it). You can also do "ruby myprog.rb\ " to escape the
space.
In either shell, whether you use single or double quotes doesn’t matter,


CCD CopyWrite Chad P. [ 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.”

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,

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.

Quoth Konrad M.:

Yes, on *nix systems this is significant (probably windows too, I’m just
ruby 'myprog.rb ’
command line shell, but will probably do so with certain GUI-oriented
means of naming files.


CCD CopyWrite Chad P. [ 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.”

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,

Konrad M. [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.

From a shell command:

mv "myscript.rb " myscript.rb

Bye bye blank.

RF

On Tue, Sep 25, 2007 at 03:41:26AM +0900, Konrad M. 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.