Newbie questions

Luke A. Kanies wrote:

We’ve discussed a parallel to perldoc, but what about CPAN? I know that
we have RAA, but CPAN’s recursive auto-installer is one of the really big
reasons so many non-programmers can use perl-based software. People are
much less likely to reinvent the wheel if it’s easy for them to explore
existing wheels, and people are much more likely to use your ruby-based
software if they just have to type ‘cpan install ’ and know it
will download, compile, and install everything.

In my experience it always tries to update Perl itself, which is a bit
cheeky if you just wanted HTML-Parser…

There was a bug in the version of CPAN shipped with 5.6.0, I believe,
which caused this. It’s long since fixed, and I think it was only one
subrelease of CPAN.

Its better than what we have, but as I’ve said before, there are better
models than CPAN to emulate (BSD ports/package tree and Debian apt-get
spring to mind).

Frankly, it doesn’t matter to me which one, as long as there’s something.
I’m already starting to feel like a crack addict without a pipe or
lighter. I wrote a small amount in perl yesterday for the first time in
about a month, and it was, um, horrible. I left out all the semicolons
and parens and dollar signs, just like in ruby, and it didn’t work. :frowning:
Unfortunately, perl has a very mature selection of modules which I’ve come
to depend on, with Net::LDAP being at the top of the list for me (I’m a
sysadmin, and I store lotsa stuff in LDAP), because it’s all perl and
includes SSL support. I expect as I use ruby more I’ll delve into helping
out on the ldap module.

So my basic point is, I definitely don’t want to go back to using perl
(wow, that was fast) but there are definitely some things I miss about it,
and I’d like to do what I can to support bringing those features to ruby,
especially if ruby doesn’t replicate perl’s mistakes.

Luke

···

On Wed, 17 Dec 2003, Rasputin wrote:


The death rate on Earth is: … (computing) … One per person.

— Daniel Carrera dcarrera@math.umd.edu wrote: > > >As for ri, I still

Well… I’m thinking of man pages here. A typical man page is a lot
longer than the vertical size of a terminal, so sending the output to
stdout is not, on itself, very useful. Something that scrolls would
make more sense. The only good thing about stdout is that you can
redirect the output and pipe it through grep, but you can already do
that. You can pipe and redirect man pages already as it is.

man <some_page> | col -b | less

man <some_page> | col -b | grep “something”

man <some_page> | col -b > ~/my_manpage

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
“TAG Editor” – http://linuxgazette.net


BT Yahoo! Broadband - Save £80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk

They’re just the standard variables to set to change your pager. The man
command is the main thing that uses them, but anything that supports
paging should use the PAGER variable. I only know about them because I
always reset mine to ‘less’ instead of ‘more’.

I haven’t yet used ri, but it should definitely be coded to use that
variable by default (which means it doesn’t use it if it’s connected to a
pipe instead of a terminal, for instance).

I’ve also written some scripts which use these variables. It’s pretty
easy.

Luke

···

On Wed, 17 Dec 2003, Daniel Carrera wrote:

On Wed, Dec 17, 2003 at 07:07:45AM +0900, Luke A. Kanies wrote:

Shouldn’t it just use the PAGER or READER environment variable? I don’t
really know what the difference is between the two, since they’re always
set the same for me, but I know perldoc uses one of them, and ri should do
the same, at least on Unix. That’s what they’re for, and it certainly
provides a more consistent interface (consistent with man, that is).

I didn’t know about those variables. How do they work?


The hypothalamus is one of the most important parts of the brain,
involved in many kinds of motivation, among other functions. The
hypothalamus controls the “Four F’s”: 1. fighting; 2. fleeing;
3. feeding; and 4. mating.
– Psychology professor in neuropsychology intro course

Yeah, I’m using it (and getting segfaults :), but it has to be compiled
against C libraries, whereas Net::LDAP is entirely in perl, depending
(almost) entirely on other perl libraries. This makes portability a
heckuva lot easier, and also reduces the amount you have to distribute to
get ldap working everywhere. I use LDAP a heckuva lot, and I generally do
ldap operations on all of my hosts sometimes, which means I need this
everywhere, and the easier that is for me, the happier I am.

As to SSL, ruby-ldap does not yet support it. I don’t know if I’m up to
helping provide it, either; most of my experience is in perl and shell,
and I’d like to continue my streak of successfully avoiding programming in
C. :slight_smile:

Luke

···

On Wed, 17 Dec 2003, Daniel Berger wrote:

“Luke A. Kanies” wrote:

Frankly, it doesn’t matter to me which one, as long as there’s something.
I’m already starting to feel like a crack addict without a pipe or
lighter. I wrote a small amount in perl yesterday for the first time in
about a month, and it was, um, horrible. I left out all the semicolons
and parens and dollar signs, just like in ruby, and it didn’t work. :frowning:
Unfortunately, perl has a very mature selection of modules which I’ve come
to depend on, with Net::LDAP being at the top of the list for me (I’m a
sysadmin, and I store lotsa stuff in LDAP), because it’s all perl and
includes SSL support. I expect as I use ruby more I’ll delve into helping
out on the ldap module.

See ruby-ldap on the RAA. Dunno about ssl support.


Computers are not intelligent. They only think they are.

I didn’t know about those variables. How do they work?

They’re just the standard variables to set to change your pager. The man
command is the main thing that uses them, but anything that supports
paging should use the PAGER variable. I only know about them because I
always reset mine to ‘less’ instead of ‘more’.

I didn’t know you could change that. That’s awesome!

I hate “more” and I’ve been really frustrated ever since I started using
this Solaris box. The fact that, by default, “man” uses “more” under
Solaris was one of the anoyances I’ve had.

I just changed it.

Thanks!

Daniel.

Yes, exactly. That’s what I was saying. You can already do
redirections and pipes with “man” so there’s no point in making “man”
send its output to stdout.

···

On Wed, Dec 17, 2003 at 07:25:54AM +0900, Thomas Adam wrote:

— Daniel Carrera dcarrera@math.umd.edu wrote: > > >As for ri, I still

Well… I’m thinking of man pages here. A typical man page is a lot
longer than the vertical size of a terminal, so sending the output to
stdout is not, on itself, very useful. Something that scrolls would
make more sense. The only good thing about stdout is that you can
redirect the output and pipe it through grep, but you can already do
that. You can pipe and redirect man pages already as it is.

man <some_page> | col -b | less

man <some_page> | col -b | grep “something”

man <some_page> | col -b > ~/my_manpage

So says the man who hasn’t looked at the perldoc source… :wink:

It actually isn’t quite as simple as it might be: the lack of decent
pipe support under Windows means I’m going to have to go through a
temporary file, which is kind of ugly. Perhaps someone might want to
look at tidying it all up later on. In the meantime, it works… :slight_smile:

Cheers

Dave

···

On Dec 16, 2003, at 16:35, Luke A. Kanies wrote:

but anything that supports
paging should use the PAGER variable. I only know about them because I
always reset mine to ‘less’ instead of ‘more’.

I’ve also written some scripts which use these variables. It’s pretty
easy.

Just a note about PAGER. Some systems (both my Debian installs, for
example) don’t define PAGER or READER, but use a symlink named ‘pager’.
It may be useful somehow to check for all of those.

My (Debian) “man man” says:

PAGER If $PAGER is set, its value is used as the name of the
program used to display the manual page. By default, exec
/usr/bin/pager -s is used.

A SuSe system here at work has the exact paragraph, so I assume it’s some
sort of standard behavior.

···

On Wed, 17 Dec 2003, Luke A. Kanies wrote:

On Wed, 17 Dec 2003, Daniel Carrera wrote:

On Wed, Dec 17, 2003 at 07:07:45AM +0900, Luke A. Kanies wrote:

Shouldn’t it just use the PAGER or READER environment variable? I don’t
really know what the difference is between the two, since they’re always
set the same for me, but I know perldoc uses one of them, and ri should do
the same, at least on Unix. That’s what they’re for, and it certainly
provides a more consistent interface (consistent with man, that is).

I didn’t know about those variables. How do they work?

They’re just the standard variables to set to change your pager. The man
command is the main thing that uses them, but anything that supports
paging should use the PAGER variable. I only know about them because I
always reset mine to ‘less’ instead of ‘more’.

I haven’t yet used ri, but it should definitely be coded to use that
variable by default (which means it doesn’t use it if it’s connected to a
pipe instead of a terminal, for instance).

I’ve also written some scripts which use these variables. It’s pretty
easy.

Luke


The hypothalamus is one of the most important parts of the brain,
involved in many kinds of motivation, among other functions. The
hypothalamus controls the “Four F’s”: 1. fighting; 2. fleeing;
3. feeding; and 4. mating.
– Psychology professor in neuropsychology intro course

Derek Lewis

===================================================================
Java Web-Application Developer

  Email    : email@lewisd.com
  Cellular : 604.312.2846
  Website  : http://www.lewisd.com

“If you’ve got a 5000-line JSP page that has “all in one” support
for three input forms and four follow-up screens, all controlled
by “if” statements in scriptlets, well … please don’t show it
to me :-). Its almost dinner time, and I don’t want to lose my
appetite :-).”
- Craig R. McClanahan

— Daniel Carrera dcarrera@math.umd.edu wrote: > > >As for ri, I
still

Well… I’m thinking of man pages here. A typical man page is a lot
longer than the vertical size of a terminal, so sending the output to
stdout is not, on itself, very useful. Something that scrolls would
make more sense. The only good thing about stdout is that you can
redirect the output and pipe it through grep, but you can already do
that. You can pipe and redirect man pages already as it is.

man <some_page> | col -b | less

man <some_page> | col -b | grep “something”

man <some_page> | col -b > ~/my_manpage

Yes, exactly. That’s what I was saying. You can already do
redirections and pipes with “man” so there’s no point in making “man”
send its output to stdout.

That’s exactly what “man” is doing here – sending its output to
stdout. Stdout being a tty device is a special case for “man” – in
this case it invokes PAGER command and redirects its own stdout to the
command’s stdin through the pipe.

Sincerely,
Gennady Bystritsky

···

On Dec 16, 2003, at 15:24, Daniel Carrera wrote:

On Wed, Dec 17, 2003 at 07:25:54AM +0900, Thomas Adam wrote:

Hey now, I think I included an “on Unix” disclaimer somewhere, although it
may have been in a different email. :slight_smile: Given my total lack of Windows
programming experience, I would not claim to understand those
complexities.

I agree that temp files are ugly; it always amazes me that so many
programmers have not discovered this.

Luke

···

On Wed, 17 Dec 2003, Dave Thomas wrote:

On Dec 16, 2003, at 16:35, Luke A. Kanies wrote:

but anything that supports
paging should use the PAGER variable. I only know about them because I
always reset mine to ‘less’ instead of ‘more’.

I’ve also written some scripts which use these variables. It’s pretty
easy.

So says the man who hasn’t looked at the perldoc source… :wink:

It actually isn’t quite as simple as it might be: the lack of decent
pipe support under Windows means I’m going to have to go through a
temporary file, which is kind of ugly. Perhaps someone might want to
look at tidying it all up later on. In the meantime, it works… :slight_smile:


"The leader of Jamestown was “John Smith” (not his real name), under
whose direction the colony engaged in a number of activities,
primarily related to starving. – Dave Barry, “Dave Barry Slept Here”

— Derek Lewis lewisd@f00f.net wrote: >

Just a note about PAGER. Some systems (both my Debian installs, for
example) don’t define PAGER or READER, but use a symlink named ‘pager’.
It may be useful somehow to check for all of those.

My (Debian) “man man” says:

PAGER If $PAGER is set, its value is used as the name of the
program used to display the manual page. By default, exec
/usr/bin/pager -s is used.

A SuSe system here at work has the exact paragraph, so I assume it’s
some
sort of standard behavior.

On my Debian System (Sid), one can do:

update-alternatives --config pager

to redefine it.

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
“TAG Editor” – http://linuxgazette.net

“ We’ll just save up your sins, Thomas and punish you for all of them at
once when you get better. The experience will probably kill you. :)”

– Benjamin A. Okopnik (Linux Gazette Contributing Editor)


BT Yahoo! Broadband - Save £80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk

Derek Lewis wrote:

A SuSe system here at work has the exact paragraph, so I assume it’s some
sort of standard behavior.

I’ve got a gentoo system, and ‘man man’ says this:

MANPAGER
If MANPAGER is set, its value is used as the name of the program to
use to display the man page. If not, then PAGER is used. If that
has no value either, /usr/bin/less -is is used.

···


Jamis Buck
jgb3@email.byu.edu

ruby -h | ruby -e ‘a=;readlines.join.scan(/-(.)[e|Kk(\S*)|le.l(…)e|#!(\S*)/) {|r| a << r.compact.first };puts “\n>#{a.join(%q/ /)}<\n\n”’

Yeah, I just wanted to make sure whoever implements this pager
functionality (Dave?) knows about /usr/bin/pager, as well as PAGER.
:slight_smile:

Derek Lewis

···

On Thu, 18 Dec 2003, Thomas Adam wrote:

— Derek Lewis lewisd@f00f.net wrote: >

Just a note about PAGER. Some systems (both my Debian installs, for
example) don’t define PAGER or READER, but use a symlink named ‘pager’.
It may be useful somehow to check for all of those.

My (Debian) “man man” says:

PAGER If $PAGER is set, its value is used as the name of the
program used to display the manual page. By default, exec
/usr/bin/pager -s is used.

A SuSe system here at work has the exact paragraph, so I assume it’s
some
sort of standard behavior.

On my Debian System (Sid), one can do:

update-alternatives --config pager

to redefine it.

– Thomas Adam

===================================================================
Java Web-Application Developer

  Email    : email@lewisd.com
  Cellular : 604.312.2846
  Website  : http://www.lewisd.com

“If you’ve got a 5000-line JSP page that has “all in one” support
for three input forms and four follow-up screens, all controlled
by “if” statements in scriptlets, well … please don’t show it
to me :-). Its almost dinner time, and I don’t want to lose my
appetite :-).”
- Craig R. McClanahan

Interesting. So there’s apparantly no consistant way of finding a pager
program.

Somehow I’m not the least bit suprised. :slight_smile:

Derek Lewis

···

On Thu, 18 Dec 2003, Jamis Buck wrote:

I’ve got a gentoo system, and ‘man man’ says this:

MANPAGER
If MANPAGER is set, its value is used as the name of the program to
use to display the man page. If not, then PAGER is used. If that
has no value either, /usr/bin/less -is is used.

===================================================================
Java Web-Application Developer

  Email    : email@lewisd.com
  Cellular : 604.312.2846
  Website  : http://www.lewisd.com

“If you’ve got a 5000-line JSP page that has “all in one” support
for three input forms and four follow-up screens, all controlled
by “if” statements in scriptlets, well … please don’t show it
to me :-). Its almost dinner time, and I don’t want to lose my
appetite :-).”
- Craig R. McClanahan

— Derek Lewis lewisd@f00f.net wrote:

Interesting. So there’s apparantly no consistant way of finding a pager
program.

It would be easy to do…

Test for either:

$PAGER

and the like…

if they’re defined use them, otherwise default to a generic one.

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
“TAG Editor” – http://linuxgazette.net

“ We’ll just save up your sins, Thomas and punish you for all of them at
once when you get better. The experience will probably kill you. :)”

– Benjamin A. Okopnik (Linux Gazette Contributing Editor)


BT Yahoo! Broadband - Save £80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk

Here’s the code I’m using in ‘ri’. Will it work across the systems that
folks use?

 for pager in [ ENV['pager'], "less", "more <" ].compact.uniq
   if system("#{pager} #{path}")
     paged = true
     break
   end
 end
 if !paged
   @options.use_stdout = true
   puts File.read(path)
 end

Cheers

Dave

···

On Dec 17, 2003, at 13:25, Thomas Adam wrote:

Interesting. So there’s apparantly no consistant way of finding a
pager
program.
It would be easy to do…
Test for either:
$PAGER
and the like…
if they’re defined use them, otherwise default to a generic one.

Looks good, but you might want to throw “/usr/bin/pager” after the ENV.

···

On Thu, 18 Dec 2003, Dave Thomas wrote:

On Dec 17, 2003, at 13:25, Thomas Adam wrote:

Interesting. So there’s apparantly no consistant way of finding a
pager
program.
It would be easy to do…
Test for either:
$PAGER
and the like…
if they’re defined use them, otherwise default to a generic one.

Here’s the code I’m using in ‘ri’. Will it work across the systems that
folks use?

 for pager in [ ENV['pager'], "less", "more <" ].compact.uniq
   if system("#{pager} #{path}")
     paged = true
     break
   end
 end
 if !paged
   @options.use_stdout = true
   puts File.read(path)
 end

Cheers

Dave

Derek Lewis

===================================================================
Java Web-Application Developer

  Email    : email@lewisd.com
  Cellular : 604.312.2846
  Website  : http://www.lewisd.com

“If you’ve got a 5000-line JSP page that has “all in one” support
for three input forms and four follow-up screens, all controlled
by “if” statements in scriptlets, well … please don’t show it
to me :-). Its almost dinner time, and I don’t want to lose my
appetite :-).”
- Craig R. McClanahan

Dave Thomas wrote:

Interesting. So there’s apparantly no consistant way of finding a pager
program.

It would be easy to do…
Test for either:
$PAGER
and the like…
if they’re defined use them, otherwise default to a generic one.

Here’s the code I’m using in ‘ri’. Will it work across the systems that
folks use?

for pager in [ ENV['pager'], "less", "more <" ].compact.uniq
  if system("#{pager} #{path}")
    paged = true
    break
  end
end
if !paged
  @options.use_stdout = true
  puts File.read(path)
end

If that ‘for’ list gets much, it’ll soon be easier to just
write your own terminal handler :slight_smile:

But it sounds like every *NIX has its own custom variable/binary.
My 2 euro is just choose an environment variable (I think PAGER is
traditional) and use it. Platform specific installers can set it if
need be. If its not set print a warning to set it maybe?

···

On Dec 17, 2003, at 13:25, Thomas Adam wrote:


Rasputin :: Jack of All Trades - Master of Nuns

In article F0A45523-30C9-11D8-BFF4-000A95676A62@pragprog.com,

···

Dave Thomas dave@pragprog.com wrote:

On Dec 17, 2003, at 13:25, Thomas Adam wrote:

Interesting. So there’s apparantly no consistant way of finding a
pager
program.
It would be easy to do…
Test for either:
$PAGER
and the like…
if they’re defined use them, otherwise default to a generic one.

Here’s the code I’m using in ‘ri’. Will it work across the systems that
folks use?

for pager in [ ENV['pager'], "less", "more <" ].compact.uniq
  if system("#{pager} #{path}")
    paged = true
    break
  end
end
if !paged
  @options.use_stdout = true
  puts File.read(path)
end

If you want to be like man etc. then you should use ENV[‘PAGER’], I
think.

Mike

mike@stok.co.uk | The “`Stok’ disclaimers” apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA

Is that a distinct program, or just an alias for ‘less’? If it’s
separate, I’ll add it.

I’m also trying to avoid absolute paths: I want it to work on Windows
too…

Cheers

···

On Dec 17, 2003, at 13:50, Derek Lewis wrote:

Looks good, but you might want to throw “/usr/bin/pager” after the ENV.