Bash未被识别 – 无法在Shell中执行编译脚本。

huangapple go评论116阅读模式
英文:

Bash not recognized — impossible to execute compilation script in shell

问题

无法使用bash编译shell脚本,因为"bash"这个术语未被识别为cmdlet、函数、脚本文件或可执行程序的名称。

我在尝试在Windows上使用Visual Studio Code编译shell脚本时遇到了问题。我按照提供的说明进行操作,但仍然出现错误。我尝试在内置终端中使用"bash"和"sh"命令,但似乎都无法被识别为有效的命令。

以下是我的代码:

#!/bin/ch
echo "Compilando MixMaster MOD"
gcc -shared -w -m32 -pthread -Wall -static Injection.cpp Script.cpp CScriptManager.cpp CMemory.cpp CHookManager.cpp CEventsHandler.cpp liblua52.a -ldl -o ../Injection.so -masm=intel

以下是我在内置编译终端中使用的基本命令:

bash compile.sh

然而,我收到一个错误消息,其中写着:"bash"这个术语未被识别为cmdlet、函数、脚本文件或可执行程序的名称。

英文:

Impossible to compile shell script with bash because "The term "bash" is not recognized as the name of a cmdlet, function, script file, or executable program."

I am currently facing an issue when trying to compile a shell script using Visual Studio Code on Windows. I followed the instructions provided, but I keep getting errors. I tried using the "bash" and "sh" commands in the built-in terminal, but neither of them seem to be recognized as a valid command.

Here is my code:

#!/bin/ch
echo "Compilando MixMaster MOD"
gcc -shared -w -m32 -pthread -Wall -static Injection.cpp Script.cpp CScriptManager.cpp CMemory.cpp CHookManager.cpp CEventsHandler.cpp liblua52.a -ldl -o ../Injection.so -masm=intel

Here is the basic command I use in the built-in compiler terminal:

bash compile.sh

However, I get an error message stating: "The term "bash" is not recognized as the name of a cmdlet, function, script file, or executable program."

答案1

得分: 1

  1. The script itself

这里有两个问题:

  1. 脚本本身
  2. 你正在在Windows上运行脚本

1. 脚本本身

第一行应该是:

#!/bin/bash

这表示正在使用bash。另一个可能的shell是

#!/bin/sh

2. 你正在使用Windows

这里更大的问题是你正在使用Windows。

Bash脚本是设计用于Unix/Linux操作系统的。

.sh或Shell脚本文件是一种在Linux操作系统中运行的脚本文件类型。它类似于Windows批处理文件,用于在计算机上运行任务。在Windows中运行.sh文件可以借助几个程序来完成,如Cygwin或Windows子系统Linux(WSL)。

完整的说明请参见这里:

https://softwarekeep.com/help-center/how-to-run-shell-script-file-in-windows#

英文:

There are two issues here:

  1. The script itself
  2. You’re running the script on windows

1. The script itself

The first line should read:

#!/bin/bash

This indicates that this is using bash.
Another posible shell is

#!/bin/sh

2.You’re using Windows

The bigger issue here is that you’re working with windows.

Bash scripts are designed to work with Unix/Linux operating systems.

The .sh or Shell Scripts file is a type of script file that runs in the Linux operating system. It's analogous to Windows batch files, which are used to run tasks on a computer. Running .sh files in Windows can be done with the help of several programs like Cygwin or the Windows Subsystem for Linux (WSL).

For full instructions see here:

https://softwarekeep.com/help-center/how-to-run-shell-script-file-in-windows#

huangapple
  • 本文由 发表于 2023年7月11日 01:16:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655946.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定