[GRASS-dev] Re: [GRASS GIS] #181: tac command missing in OSX

GRASS GIS trac at osgeo.org
Wed Jun 4 20:20:06 EDT 2008


#181: tac command missing in OSX
------------------------+---------------------------------------------------
  Reporter:  kyngchaos  |       Owner:  grass-dev at lists.osgeo.org
      Type:  defect     |      Status:  new                      
  Priority:  minor      |   Milestone:  6.3.1                    
 Component:  default    |     Version:  6.3.0                    
Resolution:             |    Keywords:  v.in.garmin, v.in.mapgen 
------------------------+---------------------------------------------------
Comment (by hamish):

 William:
 > tac is annoying in that it's part of a GNU bundle, core-utilities, I
 > couldn't find only tac source. And my first quick-n-dirty attempt to
 > compile it failed.

 1gray:
 > That's how most bundles work. One couldn't, e. g., easily compile r.what
 > without compiling the rest of GRASS as well.

 it's not like tac has many dependencies:
 {{{
 $ ldd `which tac`
         linux-gate.so.1 =>  (0xffffe000)
         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e0b000)
         /lib/ld-linux.so.2 (0xb7f5a000)
 }}}

 I assume it's a trivial C program. What's the complile error?

 While not POSIX, I think tac will be widely available. I would still like
 to hear from Cygwin/MSys/other platforms.. to me the fact that it hasn't
 been moved out of Debian's hardcore minimalist coreutils is a good
 anecdotal endorsement for wide availability.

 fwiw, on Debian/etch:
 {{{
 $ tail -r foo
 tail: invalid option -- r
 Try `tail --help' for more information.
 $ echo $?
 1
 }}}

 A not so nice for the user idea is to abort with an error if tac is not
 found.

 Glynn:
 > Off the top of my head, the only thing that I can think of is to prefix
 > each line with the line number using e.g. awk, use "sort -r", then strip
 > the line numbers.

 awk would be a great solution as this is fed directly into that. But I
 have no idea how to write that.

 Here is where it is needed- create lines for 'v.in.ascii format=standard':
 {{{
     # add vertex counts
     cat "${TMP}.gpst" | sed -e '1d' | tac | awk 'BEGIN { FS="\t" ; R=0 } \
         $1=="T" { printf(" %.7f %.7f\n", $4, $3) ; ++R } ; \
         $1=="" { printf("L %d 1\n", R) ; R=0 } END {;}' | tac >
 "${TMP}.base"
 }}}

 another thing for the future is to remove the vertex count requirement in
 the vector ascii file. I suppose it adds some level of error checking, but
 the computer can count.


 William:
 > I wonder if some sort of requirement in GRASS 7 development would be a
 good
 > idea to stick to POSIX/SUS commands?

 that is the current goal, but I see little reason to go nuts trying to be
 very strict about that, e.g. for something like `which` that may not be
 POSIX but is, literally, everywhere. ie the overwhelming common use
 exemption.

 for GRASS 7 the goal AFAIU is to replace shell scripts with more portable
 Python scripts.




 Hamish

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/181#comment:9>
GRASS GIS <http://grass.osgeo.org>


More information about the grass-dev mailing list