0

I'm investigating why application started by wine so longer outputs correct font / encoding with LANG=ru_RU.UTF-8 wine program.exe https://stackoverflow.com/questions/33379035/wine-and-cyrillic-fonts. As I started to analyze I discovered (checked on two PCs with Linux Mint slightly different versions):

var1="var" echo "$var1"  

outputs empty string / line in bash. Why? It AFAIK worked with LANG and wine. man bash:

A simple command is a sequence of optional variable assignments fol‐ lowed by blank-separated words and redirections, and terminated by a control operator.

If no command name results, the variable assignments affect the current shell environment. Otherwise, the variables are added to the environ‐ ment of the executed command and do not affect the current shell envi‐ ronment.

Alex Martian
  • 1,035
  • 1
    That's TWO commands. They need a semicolon between them var1="var"; echo "$var1" – waltinator Jan 21 '22 at 03:13
  • @waltinator, I understand two commands work. I don't why one simple command with echo does not, but one with wine does.? "This is because the shell expands the variable in the command line before it actually runs the command and at that time the variable doesn't exist." what is the point of optional variable assignments in a simple command syntax in such case? – Alex Martian Jan 21 '22 at 03:23
  • 1
    @waltinator, I saw another (not excepted) answer explains the issue much better: https://unix.stackexchange.com/a/56454/266260 echo usually a built-in and is not executed, var=value sh -c 'echo "$var"' works as I would expect. The question is closed, thanks for help. – Alex Martian Jan 21 '22 at 03:28

0 Answers0