The Artima Developer Community
Sponsored Link

Python Buzz Forum
Shebang

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
Shebang Posted: Nov 14, 2005 9:54 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: Shebang
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

I thought I was all clever because I figured out a good technique of making configuration files executable with #!. But apparently I was not so clever.

On FreeBSD I got this working nicely:

#!/usr/bin/env paster exe serve

The exe told paster that it should expect the shebang setup (config file follows, etc). And while putting paster itself as the command didn't work, /usr/bin/env parsed everything nicely for me (and since paster itself uses a shebang line to be executable, only /usr/bin/env was willing to recursively interpret that).

paster would then end up seeing an argv like ['paster', 'exe', 'serve', config_file, extra_args...] where extra_args were any arguments you passed on the command line. The environmental variable _ would be set to config_file.

Usually something that seems sensible on FreeBSD will work on Linux; in comparison to BSD tools, the GNU tools (standard on Linux) generally favor sensibility over backward compatibility, and FreeBSD seems very sensible in this case. I could only expect more sensibility on Linux, right?

Sadly, no. /usr/bin/env parses that as a request to run "paster exe serve" -- i.e., a file with embedded spaces. Sigh. It does still set _, and passes extra arguments. But I still want to know when I'm in a shebang environment, so paster can respond accordingly, and I'm not sure how to detect that. When environ['_'] != sys.argv[0]? Is that reliable? Is there another way to detect this? Any hints for MacOS (like FreeBSD?) and/or Solaris (like stupid Linux?)

Read: Shebang

Topic: Limpnodes Previous Topic   Next Topic Topic: Knife of Dreams

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use