yash_env/variable/
constants.rs

1// This file is part of yash, an extended POSIX shell.
2// Copyright (C) 2024 WATANABE Yuki
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17//! Variable name and default value constants
18
19/// The name of the `CDPATH` variable
20///
21/// The `CDPATH` variable is used by the `cd` built-in to search for
22/// directories. Its value is a colon-separated list of directories.
23pub const CDPATH: &str = "CDPATH";
24
25/// The name of the `ENV` variable
26///
27/// The `ENV` variable specifies the file to read for environment
28/// variables when the shell is invoked.
29pub const ENV: &str = "ENV";
30
31/// The name of the `HOME` variable
32///
33/// The `HOME` variable stores the path to the user's home directory.
34pub const HOME: &str = "HOME";
35
36/// The name of the `IFS` variable
37///
38/// The `IFS` variable separator characters for field splitting.
39/// The initial value is `" \t\n"`.
40pub const IFS: &str = "IFS";
41
42/// The initial value of the `IFS` variable (`" \t\n"`)
43pub const IFS_INITIAL_VALUE: &str = " \t\n";
44
45/// The name of the `LINENO` variable
46///
47/// The `LINENO` variable expands to the line number of the current command.
48pub const LINENO: &str = "LINENO";
49
50/// The name of the `OLDPWD` variable
51///
52/// The `cd` built-in sets the `OLDPWD` variable to the previous working directory.
53pub const OLDPWD: &str = "OLDPWD";
54
55/// The name of the `OPTARG` variable
56///
57/// The `OPTARG` variable is used by the `getopts` built-in to store the
58/// argument of an option.
59pub const OPTARG: &str = "OPTARG";
60
61/// The name of the `OPTIND` variable
62///
63/// The `OPTIND` variable is used by the `getopts` built-in to store the
64/// index of the next argument to be processed. The initial value is `1`.
65pub const OPTIND: &str = "OPTIND";
66
67/// The initial value of the `OPTIND` variable (`1`)
68pub const OPTIND_INITIAL_VALUE: &str = "1";
69
70/// The name of the `PATH` variable
71///
72/// The `PATH` variable stores the directories to search for executables.
73pub const PATH: &str = "PATH";
74
75/// The name of the `PPID` variable
76///
77/// The `PPID` variable stores the process ID of the parent process.
78pub const PPID: &str = "PPID";
79
80/// The name of the `PS1` variable
81///
82/// The `PS1` variable is the primary prompt string.
83/// The initial value depends on the user's privilege level.
84/// See [`PS1_INITIAL_VALUE_NON_ROOT`] and [`PS1_INITIAL_VALUE_ROOT`].
85pub const PS1: &str = "PS1";
86
87/// The initial value of the `PS1` variable for non-root user (`"$ "`)
88pub const PS1_INITIAL_VALUE_NON_ROOT: &str = "$ ";
89
90/// The initial value of the `PS1` variable for root user (`"# "`)
91pub const PS1_INITIAL_VALUE_ROOT: &str = "# ";
92
93/// The name of the `PS2` variable
94///
95/// The `PS2` variable is the secondary prompt string, which is shown
96/// when the shell expects more input to complete a command.
97/// The initial value is `"> "`.
98pub const PS2: &str = "PS2";
99
100/// The initial value of the `PS2` variable (`"> "`)
101pub const PS2_INITIAL_VALUE: &str = "> ";
102
103/// The name of the `PS4` variable
104///
105/// The `PS4` variable is used by the [`XTrace`](crate::option::XTrace) option
106/// to show the command before it is executed. The value is prefixed to the
107/// printed command. The initial value is `"+ "`.
108pub const PS4: &str = "PS4";
109
110/// The initial value of the `PS4` variable (`"+ "`)
111pub const PS4_INITIAL_VALUE: &str = "+ ";
112
113/// The name of the `PWD` variable
114///
115/// The `PWD` variable stores the current working directory.
116pub const PWD: &str = "PWD";