From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/79415 Path: news.gmane.org!not-for-mail From: Alan BRASLAU Newsgroups: gmane.comp.tex.context Subject: Re: Dash equivalent of $BASH_SOURCE (for setuptex) Date: Wed, 21 Nov 2012 18:35:31 +0100 Organization: CEA DSM-IRAMIS-SPEC Message-ID: <20121121183531.40d0959d@iram-hb-003386.extra.cea.fr> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1353519342 16893 80.91.229.3 (21 Nov 2012 17:35:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2012 17:35:42 +0000 (UTC) Cc: mailing list for ConTeXt users To: mojca.miklavec.lists@gmail.com Original-X-From: ntg-context-bounces@ntg.nl Wed Nov 21 18:35:52 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TbEDG-0008KF-EF for gctc-ntg-context-518@m.gmane.org; Wed, 21 Nov 2012 18:35:50 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 9471610368; Wed, 21 Nov 2012 18:35:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kMg6Lyt5ZTHg; Wed, 21 Nov 2012 18:35:36 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id CC4B31036C; Wed, 21 Nov 2012 18:35:36 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id F0B9C1036C for ; Wed, 21 Nov 2012 18:35:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id V9WJgAIyqzFY for ; Wed, 21 Nov 2012 18:35:35 +0100 (CET) Original-Received: from filter3-til.mf.surf.net (filter3-til.mf.surf.net [194.171.167.219]) by balder.ntg.nl (Postfix) with ESMTP id 0D21010368 for ; Wed, 21 Nov 2012 18:35:35 +0100 (CET) Original-Received: from oxalide-out.extra.cea.fr (oxalide-out.extra.cea.fr [132.168.224.8]) by filter3-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id qALHZX9r028413 for ; Wed, 21 Nov 2012 18:35:34 +0100 Original-Received: from epeire2.extra.cea.fr (epeire2.extra.cea.fr [132.167.198.32]) by oxalide.extra.cea.fr (8.14.2/8.14.2/CEAnet-Internet-out-2.3) with ESMTP id qALHZWoG014137 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 21 Nov 2012 18:35:32 +0100 Original-Received: from orpin1.extra.cea.fr (orpin1.extra.cea.fr [132.167.198.4]) by epeire2.extra.cea.fr (8.14.4/8.14.4) with ESMTP id qALHZWU6005296; Wed, 21 Nov 2012 18:35:32 +0100 (envelope-from alan.braslau@cea.fr) Original-Received: from iram-hb-003386.extra.cea.fr (charybde.extra.cea.fr [132.166.43.102]) by orpin1.extra.cea.fr (8.13.8/8.13.8/CEAnet-Extranet-out-1.2) with ESMTP id qALHZVT1023687; Wed, 21 Nov 2012 18:35:32 +0100 In-Reply-To: X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=132.168.224.8; country=FR; latitude=46.0000; longitude=2.0000; http://maps.google.com/maps?q=46.0000,2.0000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 06Iqhzxzb - 22f55672cada - 20121121 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.219 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:79415 Archived-At: Mojca, I'm not sure that I understand the question. 1. dash (Debian version of the real 100% posix-compatible Borne shell) but also /bin/sh on freebsd and other Unixes (BSD, sysV or POSIX). It is the "least common denominator" for shell scripts on most (if not all) unix-like systems, as far as I know. 2. $0 will give the the path of the script, unless it is called as ./script or script (in the current directory). In this case it will probably be "./script" or by "pathtoscript/script" in which case it will return "pathtoscript/script". The current directory can then be found by `pwd` or $PWD 3 Sourcing the script (not calling it as an executable) as "source script" or ". script" will return as $0 "/bin/bash" or "/usr/local/bin/bash" or "/bin/sh" or whatever shell is in use. This is your problem, I believe. There does not seem to be a way to determine the path to a script under a Borne shell if the script is SOURCED and not EXECUTED. Of course, a script that is executed runs a sub-shell and so this cannot be used to set variables, even environmental variables, for the calling shell. Alan On Wed, 21 Nov 2012 12:56:54 +0100 Mojca Miklavec wrote: > Hi everyone, > > Hans wrote me the following, but I'm unable to figure it out myself. > The script "setuptex" (which is in fact not urgently needed as one can > just as well export the right path, but it comes in handy) can be used > in two ways: > (a) . /path/to/context/tex/setuptex > (b) . /path/to/context/tex/setuptex /path/to/context/tex > The first approach only works if the shell interpreting setuptex knows > where the sourced script is located. > > Currently the script uses the following code and works in Bash, KSH > (and maybe some other shells as well, but I'm not sure which ones). > > if [ z"$BASH_SOURCE" != z ]; then > SCRIPTPATH="$BASH_SOURCE" > elif [ z"$KSH_VERSION" != z ]; then > SCRIPTPATH="${.sh.file}" > else > SCRIPTPATH="$0" > fi > > Hans had problems with Dash, however, I have no clue how to enable (a) > in Dash. The (b) approach always works though, so in the worst case > the answer to Hans would be "provide the path to your tex root, or > write your own script with hardcoded path ;)", but if anyone has any > clue if finding path to the executed script is possible in Dash or in > any other POSIX-compatible way, please let me know. > > Mojca > > On Mon, Nov 19, 2012 at 10:31 AM, Hans Hagen wrote: > > Hi Mojca, > > > > One of the things you need to look into is the first-setup and > > setup tex scripts (just look at the dash issues thread) .. i have > > the impression that the setuptex script doesn't find its root (own) > > under dash because it has different $0 handling (dash is the debian > > variant of bash, so we're talking of debian installations) > > > > Hans ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________