在sh shell中的函数 [英] Functions in sh shell

查看:131
本文介绍了在sh shell中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数不存在于sh shell中吗?我正在尝试将bash脚本转换为也在sh中运行,而且我无法顺利执行代码。没有函数和数组,其变得难以复制脚本功能。理想情况下,我想编写一个脚本,它可以在两个shell中运行,而不是两个稍微类似的脚本。

Do functions not exist in the sh shell? I am trying to convert a bash script to also run in sh and I'm having trouble dumbing down the code. Without functions and arrays, its become difficult to replicate the scripts functionality. Ideally I want to write one script that will run in either shell, not two slightly similar scripts.

sh ,但函数关键字缺失。将您的功能定义为

There are functions in sh, but the function keyword is missing. Define your functions as

frobnicate () {
# ....
}

使用数组,您运气不佳。

With arrays, you are out of luck.

这篇关于在sh shell中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆