-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Write termux shell environment to `/data/data/com.termux/files…
…/usr/etc/termux/termux.env` on app startup and package changes The `termux.env` can be sourced by shells to set termux environment normally exported. This can be useful for users starting termux shells with `adb` `run-as` or `root`. The file will not contain `SHELL_CMD__` variables since those are shell command specific. The items in the `termux.env` file have the format `export name="value"`. The `"`\$` characters will be escaped with `a backslash `\`, like `\"` if characters are for literal value. Note that if `$` is escaped and if its part of variable, then variable expansion will not happen if `.env` file is sourced. The `\` at the end of a value line means line continuation. Value can contain newline characters. The `termux.env` file should be sourceable by `POSIX` compliant shells like `bash`, `zsh`, `sh`, android's `mksh`, etc. Other shells with require manual parsing of the file to export variables. Related discussion #2565
- Loading branch information
1 parent
f76c20d
commit 03e1d14
Showing
8 changed files
with
196 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...d/src/main/java/com/termux/shared/shell/command/environment/ShellEnvironmentVariable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.termux.shared.shell.command.environment; | ||
|
||
public class ShellEnvironmentVariable implements Comparable<ShellEnvironmentVariable> { | ||
|
||
/** The name for environment variable */ | ||
public String name; | ||
|
||
/** The value for environment variable */ | ||
public String value; | ||
|
||
/** If environment variable {@link #value} is already escaped. */ | ||
public boolean escaped; | ||
|
||
public ShellEnvironmentVariable(String name, String value) { | ||
this(name, value, false); | ||
} | ||
|
||
public ShellEnvironmentVariable(String name, String value, boolean escaped) { | ||
this.name = name; | ||
this.value = value; | ||
this.escaped = escaped; | ||
} | ||
|
||
@Override | ||
public int compareTo(ShellEnvironmentVariable other) { | ||
return this.name.compareTo(other.name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters