Linux下的shell命令执行set -ex 错误

shell脚本:

#!/bin/bash

set -ex

export GOPATH=/go
...()

执行命令报错:

$ ./build.sh
: invalid option 2: set: -
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
./build.sh: line 3: $'\r': command not found
./build.sh: line 5: $'\r': command not found
go: unknown environment setting GO111MODULE=on  

原因:
在这里插入图片描述
格式错误:CRLF

解决方案:
修改为LF格式:
在这里插入图片描述

相关推荐

  1. Linux 系统工作中常用shell命令

    2024-01-19 03:34:03       24 阅读
  2. Android - 代码执行shell命令应用

    2024-01-19 03:34:03       62 阅读
  3. Linux shell脚本切换为root用户执行命令

    2024-01-19 03:34:03       34 阅读
  4. Linuxshelldate命令

    2024-01-19 03:34:03       19 阅读
  5. 【golang】go执行shell命令方法( exec.Command )

    2024-01-19 03:34:03       66 阅读
  6. Linux Shellecho命令详解

    2024-01-19 03:34:03       44 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-19 03:34:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-19 03:34:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-19 03:34:03       87 阅读
  4. Python语言-面向对象

    2024-01-19 03:34:03       96 阅读

热门阅读

  1. nlk学习笔记 新闻摘要自动提取

    2024-01-19 03:34:03       47 阅读
  2. Pandas实战100例 | 案例 49: 数值运算

    2024-01-19 03:34:03       50 阅读
  3. D - Disastrous Doubling

    2024-01-19 03:34:03       60 阅读
  4. 配置git环境

    2024-01-19 03:34:03       49 阅读
  5. 【Git】GitHub上手动解决冲突

    2024-01-19 03:34:03       53 阅读
  6. iptables使用

    2024-01-19 03:34:03       41 阅读
  7. PHP 数组面试题

    2024-01-19 03:34:03       51 阅读
  8. 解密Spring Boot的定时任务

    2024-01-19 03:34:03       48 阅读
  9. dpwwn:01

    dpwwn:01

    2024-01-19 03:34:03      57 阅读
  10. c语言之分支语句

    2024-01-19 03:34:03       53 阅读