'CMD to bash script conversion semicolumn
I am trying to convert a CMD script (.bat) into a .sh script on Linux side.
I did not find a proper documentation for instance for the following lines
set PATH="${PATH1}%;${PATH_NAME};"
another_script.bat -create "%LocalDestination%TEST;%LocalDestination%" -e %GenericEnvironementName% -d "%SettingsPath%/Env"
For the first one it is an export but I do not know it is like the if condition?
${PATH1}=${PATH_NAME}
export PATH=$PATH1
for the second one the expression
"%LocalDestination%TEST;%LocalDestination%"
it's like an assignement? why we put the %
at the end?
$LocalDestination$TEST = $LocalDestination
%GenericEnvironementName%
will be $GenericEnvironementName
%SettingsPath%/Env >>> $SettingsPath/Env?
Solution 1:[1]
- Variables in dos bat files are delimited with
%
, before AND after. So%VAR%
is replaced by the value ofVAR
. set PATH="${PATH1};${PATH_NAME};"
assigns the values ofPATH1
andPATH_NAME
to variablePATH
, separated by;
.- In Bash you would write:
export PATH="$PATH1;$PATH_NAME"
- Therefore, yes, any variable referencing is bash is done with
$
before the variable name. So%TATA%
becomes$TATA
. - Example:
%SettingsPath%/Env
-->${SettingsPath}/Env
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |