vscode configures shell script, runs shell script on window

  1. Set the git-bash language file to a file with a .sh suffix to match the .sh file.
  2. Set the default processor of the command line shell to bash.exe, which is used to parse .sh files on the command line.
"code-runner.languageIdToFileExtensionMap": {
    "bat": ".bat",
    "powershell": ".ps1",
    "typescript": ".ts",
    "git-bash": ".sh"
},
"terminal.integrated.shell.windows": "D:\\soft\\Git\\bin\\bash.exe",

The bottom line is the address of bash, not git-bash.

write shell

#!/bin/bash
your_name="黑胡椒"
echo $your_name
echo ${your_name}
str1='test'
str2="demo"
echo $str1 $str2
echo ${#str1}
echo ${str1:1:3}
for((i=0;i<3;i++));
do
  echo $i
done

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish