|
|
setting $0
With the following file, t.rb,
----
#!/usr/bin/env ruby
$0 = 'My Application'
puts $0
----
the output is:
$ ruby -v t.rb
ruby 1.8.1 (2003-12-05) [i686-linux]
My Applicati
Why does it get truncated?
|
|
0
|
|
|
|
Reply
|
vjoel (2600)
|
12/18/2003 6:08:39 AM |
|
>
> With the following file, t.rb,
>
> ----
> #!/usr/bin/env ruby
>
> $0 = 'My Application'
> puts $0
> ----
>
> the output is:
>
> $ ruby -v t.rb
> ruby 1.8.1 (2003-12-05) [i686-linux]
> My Applicati
>
> Why does it get truncated?
8.3 format? ;) (It's the right number of characters, just no dot.)
|
|
0
|
|
|
|
Reply
|
gsinclair1 (862)
|
12/18/2003 6:21:35 AM
|
|
On Thu, Dec 18, 2003 at 03:08:39PM +0900, Joel VanderWerf wrote:
> #!/usr/bin/env ruby
>
> $0 = 'My Application'
> puts $0
> ----
>
> the output is:
>
> $ ruby -v t.rb
> ruby 1.8.1 (2003-12-05) [i686-linux]
> My Applicati
Looks like a bug. I find it suggestive that the length of the truncated
string is 12 characters - the same length as an 8+3 filename including the
period.
It gets even more interesting, however: the same code works as an -e
expression:
$ ruby -ve '$0 = "My Application"; puts $0'
ruby 1.8.1 (2003-12-05) [i686-linux]
My Application
(Different quotes for ease of keeping the shell out; I verified that
changing the quotes in t.rb to double didn't affect the beahvior)
-Mark
|
|
0
|
|
|
|
Reply
|
markjreed1 (198)
|
12/18/2003 6:22:14 AM
|
|
Hi,
In message "setting $0"
on 03/12/18, Joel VanderWerf <vjoel@PATH.Berkeley.EDU> writes:
|With the following file, t.rb,
|
|----
|#!/usr/bin/env ruby
|
|$0 = 'My Application'
|puts $0
|----
|
|the output is:
|
|$ ruby -v t.rb
|ruby 1.8.1 (2003-12-05) [i686-linux]
|My Applicati
|
|Why does it get truncated?
It's a Linux restriction. Wishing if linux has setproctitle(3).
Interestingly, my linux box has a setproctitle man page.
matz.
|
|
0
|
|
|
|
Reply
|
matz (1855)
|
12/18/2003 8:10:20 AM
|
|
I experienced the same problem just 2 weeks ago. It happens on Solaris
as well as on Linux. I was about to post it here, when I found a work
around: you can use $0.replace instead of $0=
Gennady.
Yukihiro Matsumoto wrote:
> Hi,
>
> In message "setting $0"
> on 03/12/18, Joel VanderWerf <vjoel@PATH.Berkeley.EDU> writes:
>
> |With the following file, t.rb,
> |
> |----
> |#!/usr/bin/env ruby
> |
> |$0 = 'My Application'
> |puts $0
> |----
> |
> |the output is:
> |
> |$ ruby -v t.rb
> |ruby 1.8.1 (2003-12-05) [i686-linux]
> |My Applicati
> |
> |Why does it get truncated?
>
> It's a Linux restriction. Wishing if linux has setproctitle(3).
> Interestingly, my linux box has a setproctitle man page.
>
> matz.
>
|
|
0
|
|
|
|
Reply
|
gfb1 (202)
|
12/18/2003 3:47:56 PM
|
|
|
4 Replies
39 Views
(page loaded in 0.08 seconds)
|
|
|
|
|
|
|
|
|