0

Is it possible to put comments in environment variables, like %PATH%, HOME, $PS1, etc., or part of them? I assume if this is possible it would be done in the same way as various scripting languages, for example in JavaScript we would use

// This is an empty line

to comment a whole line, or

This is JavaScript/*version 2.2*/. // "version 2.2" is commented out

I would like to mainly use this for the PATH variable, so if there is more than 1 file with the same name in different folders I can use 1 file sometimes and the other file other times.

Another use for this is sometimes I may not want to use a program's PATH variable but I don't want to completely uninstall it and I want to keep the PATH variable there in case I forget it later (and am too lazy to look it up). As an example, for Git Bash (msysgit) & Cygwin, if I don't want to use these programs all the time because I don't want to have my system feel like Linux all the time, one easy way to remove much of the Linux functionality is to remove that program's parts of the PATH variable, which removes the program's root folder as the system's pseudo-root folder.

I would like this to be a cross-platform solution, as I have a Windows 8.1 computer but have some Linux VM's.

4

2 回答 2

1

我想主要将它用于 PATH 变量,所以如果在不同的文件夹中有多个同名文件,我有时可以使用 1 个文件,其他时候可以使用另一个文件。

尝试将您想要使用的内容放在旧版本的前面(左侧),即如果您希望使用C:\current_folder而不是D:\old_folder,只需将路径编辑为

C:\current_folder;D:\old_folder;

(注意条目的顺序)

于 2015-05-13T04:13:38.437 回答
1

您不能使用 * 或 // 注释掉 Windows 中的环境变量,但上述更改路径顺序的方法效果很好。我将此方法与 Python 变体(2 和 3)一起使用。

于 2017-08-10T15:11:59.230 回答