小于博客 小于博客
首页
  • Java学习笔记
  • Docker专区
  • 实战教程
  • Shell
  • 内存数据库
  • Vue学习笔记
  • Nginx
  • Php
  • CentOS
  • Docker
  • Gitlab
  • GitHub
  • MySql
  • MongoDB
  • OpenVPN
  • 配置文件详解
  • Other
  • ELK
  • K8S
  • Nexus
  • Jenkins
  • 随写编年
  • 电影音乐
  • 效率工具
  • 博客相关
  • 最佳实践
  • 迎刃而解
  • 学习周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • 网站状态 (opens new window)
    • json2go (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

小于博客

行者常至,为者常成
首页
  • Java学习笔记
  • Docker专区
  • 实战教程
  • Shell
  • 内存数据库
  • Vue学习笔记
  • Nginx
  • Php
  • CentOS
  • Docker
  • Gitlab
  • GitHub
  • MySql
  • MongoDB
  • OpenVPN
  • 配置文件详解
  • Other
  • ELK
  • K8S
  • Nexus
  • Jenkins
  • 随写编年
  • 电影音乐
  • 效率工具
  • 博客相关
  • 最佳实践
  • 迎刃而解
  • 学习周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • 网站状态 (opens new window)
    • json2go (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

    • 记一次关于tomcat的踩坑的经历
    • 解决VNC连接闪退的问题
    • 一次升级线上服务器内核的经历
    • 服务器存储不够了之直接挂载一块儿新磁盘的操作
    • 服务器存储不够了之在原逻辑卷上扩容的操作
    • 解决php-fpm启动之后没有9000端口的问题
    • 解决MySQL问题:Got error 28 from storage engine
    • 解决git clone报错Peer’s Certificate has expired的问题
    • Linux的普通用户bash突然报错bash fork retry No child processes的解决办法
    • 分析解决脚本执行时总是报出command not found
    • confluence数据目录满了
    • 利用prlimit动态修改应用进程的最大文件打开数
    • vim复制代码包含注释时格式会乱掉解决办法
    • python如何快速迁移依赖库
    • YUM安装提示--skip-broken-to-work-around-the-problem
    • 请求nginx返回413的错误
    • Linux系统环境变量被覆盖所有命令找不到怎么办
    • Centos7更改yum源为阿里云
    • node编译报错
    • git-commit错了如何更改
    • 关于执行journalctl时的一个报错
    • yum安装epel之后报错
    • umount卸载磁盘的时候提示busy
    • pip安装依赖时报ssl的问题
    • lavel框架缓存目录的问题
    • Debian系统中执行shell报错unexpected operator
    • Vuepress项目编译时报routines的错误
    • 一次因为Mac系统升级引发的ssh无法免密登陆的问题
  • 学习周刊

  • 积累
  • 迎刃而解
小于博客
2022-05-21

Debian系统中执行shell报错unexpected operator

新的Jenkins测试环境通过docker搭建,官方镜像的基础镜像使用的是Debian系统,在执行到一些shell步骤的时候,总是会报如下错误:

/var/jenkins_home/workspace/ops/test-eryajf-blog@tmp/durable-8207aae1/script.sh: 5: [: ALL: unexpected operator
1

这是由于Debian系统以及Ubuntu系统在最近新系统中,默认的sh软链到的是dash,而非bash。

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Mar 28 08:00 /bin/sh -> dash
1
2

通过执行如下命令,可以将sh软链到bash上。

$ dpkg-reconfigure dash
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Configuring dash
----------------

The system shell is the default command interpreter for shell scripts.

Using dash as the system shell will improve the system's overall performance. It does not alter the shell presented to interactive users.

Use dash as the default system shell (/bin/sh)? [yes/no] no  需在此处输入no

Removing 'diversion of /bin/sh to /bin/sh.distrib by dash'
Adding 'diversion of /bin/sh to /bin/sh.distrib by bash'
Removing 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

更改成功之后,再看一下当前sh的软链:

ls -l /bin/sh
lrwxrwxrwx 1 root root 4 May 21 22:35 /bin/sh -> bash
1
2

然后再运行脚本就不会报刚刚那个错了。

上次更新: 2024/02/28, 13:00:35

← lavel框架缓存目录的问题 Vuepress项目编译时报routines的错误→

最近更新
01
SpringBoot 快速实现 api 加密!
03-21
02
SpringBoot整合SQLite
03-07
03
SpringBoot配置使用H2数据库的简单教程
02-21
更多文章>
Theme by Vdoing | Copyright © 2017-2024 | 点击查看十年之约 | 豫ICP备2022014539号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式