[racket] calling osx binaries from racket

From: Stephen De Gabrielle (stephen.degabrielle at acm.org)
Date: Tue Aug 24 06:23:35 EDT 2010

Hi,

This isn't actually a problem with racket, but just a helpful tip for OS X
user who want to use the racket system commands for exectables they have
installed themselves. (I found it looking at the documentation for an OS X
GIT tool)

My problem was I couldn't get (system command) to call newly installed
executables.
 - adding it to the $PATH doesn't work for OSX (I believe it does work for
windows, though I don't know the situation on linux?)

The attached script adds the path /usr/local/fossil/bin to the
~/.MacOSX/environment.plist,  making the executables in that folder
available to DrRacket, as demonstrated by the keybinding.rkt
user-defined-keybindings file attached as a demonstration/test.

User defined keybindings are a excellent way to extend DrRacket, and this
little tip should help any OS X users who want to use them with their own
tools. (git?)

Cheers,

Stephen


-- 

#!/bin/sh

append_path () {
  input="$1"
  value="$2"
  if ! echo $input | /usr/bin/egrep -q "(^|:)$value($|:)" ; then
     if [ "$3" = "after" ] ; then
        echo $input:$value
     else
        echo $value:$input
     fi
  else
    echo $input
  fi
}

append_plist_var() {
  name="$1"
  append_value="$2"
  default_value="$3"
  current_value="`defaults read $HOME/.MacOSX/environment ${name}`"
  [ ! "$current_value" ] && current_value="$default_value"
  new_value="`append_path "$current_value" "$append_value" after`"
  defaults write $HOME/.MacOSX/environment "$name" "$new_value"
  if [ "$current_value" == "$new_value" ]; then
    echo "No change to $name in ~/.MacOSX/environment.plist"
  else
    echo "Variable $name in ~/.MacOSX/environment.plist changed from
'$current_value' to '$new_value'"
  fi
}

append_plist_var PATH "/usr/local/fossil/bin"
"/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin"

pushd "$HOME"

popd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100824/fad21213/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keybinding.rkt
Type: application/octet-stream
Size: 735 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100824/fad21213/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setup fossil PATH for non-terminal programs.sh
Type: application/x-sh
Size: 956 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100824/fad21213/attachment.sh>

Posted on the users mailing list.