ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* System variable HOME
@ 2012-11-02 16:28 Procházka Lukáš Ing. - Pontex s. r. o.
  2012-11-03 11:43 ` Sietse Brouwer
  2012-11-04 23:15 ` Sietse Brouwer
  0 siblings, 2 replies; 8+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-11-02 16:28 UTC (permalink / raw)
  To: ConTeXt

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.Tx>set 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:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-02 16:28 System variable HOME Procházka Lukáš Ing. - Pontex s. r. o.
@ 2012-11-03 11:43 ` Sietse Brouwer
  2012-11-03 20:47   ` Procházka Lukáš
  2012-11-04 23:15 ` Sietse Brouwer
  1 sibling, 1 reply; 8+ messages in thread
From: Sietse Brouwer @ 2012-11-03 11:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-03 11:43 ` Sietse Brouwer
@ 2012-11-03 20:47   ` Procházka Lukáš
  0 siblings, 0 replies; 8+ messages in thread
From: Procházka Lukáš @ 2012-11-03 20:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sat, 03 Nov 2012 12:43:26 +0100, Sietse Brouwer <sbbrouwer@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-02 16:28 System variable HOME Procházka Lukáš Ing. - Pontex s. r. o.
  2012-11-03 11:43 ` Sietse Brouwer
@ 2012-11-04 23:15 ` Sietse Brouwer
  2012-11-05  8:15   ` Procházka Lukáš Ing. - Pontex s. r. o.
  2012-11-05 17:46   ` Hans Hagen
  1 sibling, 2 replies; 8+ messages in thread
From: Sietse Brouwer @ 2012-11-04 23:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-04 23:15 ` Sietse Brouwer
@ 2012-11-05  8:15   ` Procházka Lukáš Ing. - Pontex s. r. o.
  2012-11-05 17:46   ` Hans Hagen
  1 sibling, 0 replies; 8+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-11-05  8:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,

I can answer just the first point -

On Mon, 05 Nov 2012 00:15:17 +0100, Sietse Brouwer <sbbrouwer@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:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-04 23:15 ` Sietse Brouwer
  2012-11-05  8:15   ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2012-11-05 17:46   ` Hans Hagen
  2012-11-09 17:28     ` Sietse Brouwer
  2012-11-19  8:16     ` Procházka Lukáš Ing. - Pontex s. r. o.
  1 sibling, 2 replies; 8+ messages in thread
From: Hans Hagen @ 2012-11-05 17:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-05 17:46   ` Hans Hagen
@ 2012-11-09 17:28     ` Sietse Brouwer
  2012-11-19  8:16     ` Procházka Lukáš Ing. - Pontex s. r. o.
  1 sibling, 0 replies; 8+ messages in thread
From: Sietse Brouwer @ 2012-11-09 17:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> 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 <pragma@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: System variable HOME
  2012-11-05 17:46   ` Hans Hagen
  2012-11-09 17:28     ` Sietse Brouwer
@ 2012-11-19  8:16     ` Procházka Lukáš Ing. - Pontex s. r. o.
  1 sibling, 0 replies; 8+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-11-19  8:16 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 05 Nov 2012 18:46:18 +0100, Hans Hagen <pragma@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:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-11-19  8:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-02 16:28 System variable HOME Procházka Lukáš Ing. - Pontex s. r. o.
2012-11-03 11:43 ` Sietse Brouwer
2012-11-03 20:47   ` Procházka Lukáš
2012-11-04 23:15 ` Sietse Brouwer
2012-11-05  8:15   ` Procházka Lukáš Ing. - Pontex s. r. o.
2012-11-05 17:46   ` Hans Hagen
2012-11-09 17:28     ` Sietse Brouwer
2012-11-19  8:16     ` Procházka Lukáš Ing. - Pontex s. r. o.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).