From: Derek Lewis Date: 2003-12-18T05:32:03+09:00 Subject: Re: paging (was Newbie questions) On Thu, 18 Dec 2003, Dave Thomas wrote: > > On Dec 17, 2003, at 13:50, Derek Lewis wrote: > > > > > Looks good, but you might want to throw "/usr/bin/pager" after the ENV. > > > > Is that a distinct program, or just an alias for 'less'? If it's > separate, I'll add it. That depends on the system configuration. It's usually a symlink to 'less' or 'more', depending on configuration. The thing is, it may be pointing to something the user specificly prefers for some reason, so we should probably be checking it. > I'm also trying to avoid absolute paths: I want it to work on Windows > too... Hmm... I'd kind of forgotten about that. But... trying to run "/usr/bin/pager" would just behave the same as it would on Unix if that file didn't exist, wouldn't it? Which would be (I think) the behavior we would want, so it just goes on to try the next pager program. Hmm... I'm looking at perldoc, and it looks like there's some hefty OS checking going on in their pager selection. (my $pager = <<'/../') =~ s/\s*\z//; /usr/bin/sensible-pager /../ my @pagers = (); push @pagers, $pager if -x $pager; if ($Is_MSWin32) { push @pagers, qw( more< less notepad ); unshift @pagers, $ENV{PAGER} if $ENV{PAGER}; for (@found) { s,/,\\,g } } elsif ($Is_VMS) { push @pagers, qw( most more less type/page ); } elsif ($Is_Dos) { push @pagers, qw( less.exe more.com< ); unshift @pagers, $ENV{PAGER} if $ENV{PAGER}; } else { if ($^O eq 'os2') { unshift @pagers, 'less', 'cmd /c more <'; } push @pagers, qw( more less pg view cat ); unshift @pagers, $ENV{PAGER} if $ENV{PAGER}; } unshift @pagers, $ENV{PERLDOC_PAGER} if $ENV{PERLDOC_PAGER}; lewisd@derlewi:~$ cat /usr/bin/sensible-pager #!/bin/bash shopt -s execfail exec ${PAGER:-pager} "$@" exec more "$@" echo "Couldn't find a pager!" 1>&2 echo "Set the \$PAGER environment variable to your desired pager." 1>&2 exit 1 lewisd@derlewi:~$ I don't know any perl, so I can't really comment too much on how all that works, other than that it's using a different pager list for different OS's. Can/should we do something similar? (Maybe "can" is a moot question, seeing as ruby seems to be able to do anything I've asked it to, short of dishes or laundry ;) 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