[csw-maintainers] opensolaris command more compliant - what is opencsw solution ?

Ben Walton bwalton at opencsw.org
Sat Apr 3 18:54:53 CEST 2010


Excerpts from rupert THURNER's message of Sat Apr 03 10:03:02 -0400 2010:

Hi Rupert,

> the mercurial testsuite relies on which returning something non 0 in
> case nothing is found. the standard solaris csh script returns 0.

The following ruby script, if placed with precedence somewhere in your
PATH during the mercurial build[1] would likely work.  It's not full
featured, but should do the trick, I think.  You'd want to then add
CSWruby as a build prerequisite too (or rewrite in perl or python,
etc).

--snip--
#!/opt/csw/bin/ruby -w
ENV['PATH'].split(':').each do |p|
  begin
    prog = File.join(p, ARGV[0])
    f = File.stat(prog)
  rescue Errno::ENOENT => e
    # file doesn't exist in this path
    # this also catches dangling symlinks...
    next
  else
    # file does exist.  is it usable?
    if f.file? and f.executable?
      puts prog
      exit 0
    end
  end
end

$stderr.puts "#{ARGV[0]} not found in #{ENV['PATH'].gsub(':', ' ')}"
exit 1
--snip--

I wasn't aware of this breakage in `which.` There is a proper which
available here: http://www.xs4all.nl/~carlo17/which/.  Looks like
Maciej was working on it already...Maciej, are there build issues with
it?

Thanks
-Ben

[1] Add the script as 'which' in your files/ directory, make it +x and
    do: PATH := $(FILEDIR):$(PATH) in your GAR recipe...this is rough,
    but should be close to what you need to make it work.
-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302



More information about the maintainers mailing list