Re: [NTG-context] System variable HOME

2012-11-19 Thread Procházka Lukáš Ing . - Pontex s . r . o .

On Mon, 05 Nov 2012 18:46:18 +0100, Hans Hagen pra...@wxs.nl wrote:


On 11/5/2012 12:15 AM, Sietse Brouwer wrote:


(2) why would mtxrun set the variables and risk overwriting something?
The comments suggest it is for the benefit of the cnf files, but still
--- why overwrite?
 ossetenv(HOME,   homedir) -- can be used in unix cnf files
 ossetenv(USERPROFILE,homedir) -- can be used in windows cnf files



Wouldn't be better to set the HOME variable ONLY in the case it has not been 
defined?

If I keep the code mentioned by Sietse - Below: relevant code from mtxrun, lines 
11681-11696


local homedir = --osgetenv(ostype == windows and 'USERPROFILE' or 'HOME') 
or ''

osgetenv(HOME) or ostype == windows and 
osgetenv('USERPROFILE') -- - MY PROPOSAL HERE

if not homedir or homedir ==  then
homedir = char(127) -- we need a value, later we wil trigger on it
end

homedir = file.collapsepath(homedir)

ossetenv(HOME,   homedir) -- can be used in unix cnf files
ossetenv(USERPROFILE,homedir) -- can be used in windows cnf files

environment.homedir = homedir


Lukas




it just sets them local (for this run + subruns)

Hans



--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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
___


Re: [NTG-context] System variable HOME

2012-11-09 Thread Sietse Brouwer
 normally you can better look in a lua file in the tex/context/source path as
 that is the real source .. mtxrun is just a merge

So noted at http://wiki.contextgarden.net/Mtxrun (where there is also
the argument reference of each subscript, and space for people to
document them further, by the way).

--Sietse

On Mon, Nov 5, 2012 at 6:46 PM, Hans Hagen pra...@wxs.nl wrote:
 On 11/5/2012 12:15 AM, Sietse Brouwer wrote:

 (2) why would mtxrun set the variables and risk overwriting something?
 The comments suggest it is for the benefit of the cnf files, but still
 --- why overwrite?
  ossetenv(HOME,   homedir) -- can be used in unix cnf files
  ossetenv(USERPROFILE,homedir) -- can be used in windows cnf files


 it just sets them local (for this run + subruns)

 they are set just in case one has cross platform scripts (like me)


 Below: relevant code from mtxrun, lines 11681-11696


 normally you can better look in a lua file in the tex/context/source path as
 that is the real source .. mtxrun is just a merge

 Hans

 -
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
  | www.pragma-pod.nl
 -
___
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
___


Re: [NTG-context] System variable HOME

2012-11-05 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

I can answer just the first point -

On Mon, 05 Nov 2012 00:15:17 +0100, Sietse Brouwer sbbrou...@gmail.com wrote:


Lukáš wrote:

it seems that Ctx [re]defines the system variable HOME on its run


Did some digging, and indeed it does. This is what happens, if I read
the code correctly (lines 11681-11696 of context/bin/mtxrun):
* `homedir` is read from the environment variable USERPROFILE on
Windows, and from HOME on Linux.
* both USERPROFILE and HOME (and environment.homedir) are then set to
the value of `homedir`.

Questions this raises:

(1) Windows does not seem to use HOME


That's true, that's why I decided to use a variable of this name.


(it's not in any of the lists of
environment variables that I found), only HOMEDRIVE and HOMEPATH, so
what do you use it for?


That's true, too.

The HOMEPATH variable points to c:/Document and Settings/blablabla - I didn't want to change this variable to 
my value d:/Lukas as many programs may suppose location c:/Document and Settings and don't 
need to use %HOMEPATH% when they want to obtain the directory of user settings/data.

So, if possible (= when I CAN AFFECT some program behavior; like Ctx, gnuplot and other 
command-line oriented programs) I'm using my variable HOME.

Also, I redirected My Documents folder (under Windows) to d:/Lukas.

Surprisingly, when you do this redirection (via My Documents properties - Change Location or 
similar button), My Documents location is changed but HOMEPATH variable keeps its default settings, 
c:/Documents and Settings/

So the state of user documents folder is a bit schizophrenic from this moment as My Documets 
are redirected to d:/Lukas whilst HOMEPATH points to c:/Documents and Settings/

As My Documents location is not detectable from the command line (supposing you don't use a tool which 
reads a key in the registry which contains the value of My Documents location), I defined (on all 
computers, notebooks etc. I'm working with) a new system [local] variable HOME which points to the same dir 
as My Documents and which was not in use by Windows.

There was no name HOME collision problem so far - so I choose this name.

Best regards,

Lukas


--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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
___


Re: [NTG-context] System variable HOME

2012-11-05 Thread Hans Hagen

On 11/5/2012 12:15 AM, Sietse Brouwer wrote:


(2) why would mtxrun set the variables and risk overwriting something?
The comments suggest it is for the benefit of the cnf files, but still
--- why overwrite?
 ossetenv(HOME,   homedir) -- can be used in unix cnf files
 ossetenv(USERPROFILE,homedir) -- can be used in windows cnf files


it just sets them local (for this run + subruns)

they are set just in case one has cross platform scripts (like me)


Below: relevant code from mtxrun, lines 11681-11696


normally you can better look in a lua file in the tex/context/source 
path as that is the real source .. mtxrun is just a merge


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] System variable HOME

2012-11-04 Thread Sietse Brouwer
Lukáš wrote:
 it seems that Ctx [re]defines the system variable HOME on its run

Did some digging, and indeed it does. This is what happens, if I read
the code correctly (lines 11681-11696 of context/bin/mtxrun):
* `homedir` is read from the environment variable USERPROFILE on
Windows, and from HOME on Linux.
* both USERPROFILE and HOME (and environment.homedir) are then set to
the value of `homedir`.

Questions this raises:

(1) Windows does not seem to use HOME (it's not in any of the lists of
environment variables that I found), only HOMEDRIVE and HOMEPATH, so
what do you use it for?

(2) why would mtxrun set the variables and risk overwriting something?
The comments suggest it is for the benefit of the cnf files, but still
--- why overwrite?
ossetenv(HOME,   homedir) -- can be used in unix cnf files
ossetenv(USERPROFILE,homedir) -- can be used in windows cnf files

(3) What is the 'correct' thing to do here? Should HOME be the same as
USERPROFILE? Should you not be using HOME? Should mtxrun not be
overwriting HOME?

My knowledge ends here --- anyone know any answers to any questions?

Cheers and good luck,
Sietse

Below: relevant code from mtxrun, lines 11681-11696

local homedir = osgetenv(ostype == windows and 'USERPROFILE' or
'HOME') or ''

if not homedir or homedir ==  then
homedir = char(127) -- we need a value, later we wil trigger on it
end

homedir = file.collapsepath(homedir)

ossetenv(HOME,   homedir) -- can be used in unix cnf files
ossetenv(USERPROFILE,homedir) -- can be used in windows cnf files

environment.homedir = homedir
___
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
___

Re: [NTG-context] System variable HOME

2012-11-03 Thread Sietse Brouwer
 it seems that Ctx [re]defines the system variable HOME on its run;

This is not an answer, but a guess: Could it be that your interactive
shell uses one setting, and the non-interactive shell uses another?
I'm only guessing here, I don't know much about Windows
administration; I just remember being driven to despair by a similar
'these settings are not used if the shell is not interactive' problem
under Linux.

--Sietse
___
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
___


Re: [NTG-context] System variable HOME

2012-11-03 Thread Procházka Lukáš

On Sat, 03 Nov 2012 12:43:26 +0100, Sietse Brouwer sbbrou...@gmail.com wrote:


it seems that Ctx [re]defines the system variable HOME on its run;


This is not an answer, but a guess: Could it be that your interactive
shell uses one setting, and the non-interactive shell uses another?


I'm using the windows default shell - cmd.exe;
it is interactive in the manner that you can type a command on the command 
prompt and the command (or a program) is executed.

In Windows, when a process is created, it inherits current system variables.

If you launch a program from cmd.exe (= command line), the program (process) 
inherits all system variables existing in the moment of launching in the 
environment of the session of that cmd.exe.

(Various instances of cmd.exe don't inter-corporate in the point-of-view of 
system variables.)

Moreover, when the launched program changes a system variable, it changes it 
just in its-own scope;
so values of system variables of the calling cmd.exe are not affected.

BTW: I solved the problem a bit hacky (and hopefully temporarily, if we'll find a 
better solution): I'm calling SET HOME.ORG=%HOME% right before I launch context.exe;
so I can access my previous variable value.

Somewhere inside a Ctx source within a Lua scope I call:


local home = os.getenv(HOME.ORG) or os.getenv(HOME) or MyUsualHomePath


It works but it is not nice enough.

Best regards,

Lukas



I'm only guessing here, I don't know much about Windows
administration; I just remember being driven to despair by a similar
'these settings are not used if the shell is not interactive' problem
under Linux.

--Sietse



___
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
___


[NTG-context] System variable HOME

2012-11-02 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

it seems that Ctx [re]defines the system variable HOME on its run; compare:

- command line:


C:\Lukas\Jobs\HubI-ISK.DSP\SO_210\Statics.Txset home
Home=C:\Lukas
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\LPR


- and result of:

 t-Home.mkiv
\starttext
  \directlua{context(os.getenv(Home))}
\stoptext


- C:/Documents and Settings/LPR

Is it possible to avoid this substitution anyhow? - I'd need to keep (or access) the 
original value (= C:\Lukas).

TIA.

Best regards,

Lukas


--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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
___