[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to change directory of work?


On 4/13/25 5:26 PM, Benoît Minisini wrote:
Le 13/04/2025 à 23:18, Bruce Steers a écrit :

[snip]>>
there is no such thing as a "working directory" in gambas.

every time you run Shell you create a new process so you cannot run "cd dir" in one Shell command then another Shell command be in that dir.

You could do it in one single Shell command by using a newline..

Shell "cd /home/user/path/to/program\n" &
       "executable_cli"

You could also chain shell commands together using the ";" or "&&" operators, eg.:
Shell "cd /home/user/path/to/program; executable_cli", or
Shell "cd /home/user/path/to/program && executable_cli"

If you use the "&&" logical AND operator and the "cd" command exits with a failure code, executable_cli will not be executed.

[snip]>
Otherwise you can actually specify the working directory in Exec or Shell by specifying it the "PWD" environment variable.

Exec ["pwd"] With ["PWD=/root"] Wait

It's an undocumented Gambas feature.

Actually, Benoît, it is documented on the SHELL page in the "Environment" section:
https://gambaswiki.org/wiki/lang/shell#t3


--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


Follow-Ups:
Re: how to change directory of work?Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
how to change directory of work?roberto.premoli@xxxxxxxxxx
Re: how to change directory of work?Bruce Steers <bsteers4@xxxxxxxxx>
Re: how to change directory of work?Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>