官术网_书友最值得收藏!

  • Bash Cookbook
  • Ron Brash Ganesh Naik
  • 162字
  • 2021-07-23 19:17:31

Including source files

In addition to functions, we can also create multiple scripts and include them such that we can utilize any shared variables of functions.

Let's say we have a library or utility script that contains a number of functions useful for creating files. This script by itself could be useful or reusable for a number of scripting tasks, so we make it program neutral. Then, we have another script, but this one is dedicated to a single task: performing useless file system operations (IO). In this case, we would have two files:

  1. io_maker.sh (which includes library.sh and uses library.sh functions)
  2. library.sh (which contains declared functions, but does not execute them)

The io_maker.sh script simply imports or includes the library.sh script and inherits knowledge of any global variables, functions, and other inclusions. In this manner, io_maker.sh effectively thinks that these other available functions are its own and can execute them as if they were contained within it.

主站蜘蛛池模板: 米易县| 岑巩县| 霞浦县| 海伦市| 渭南市| 大同市| 兴业县| 古蔺县| 甘南县| 广安市| 栖霞市| 大竹县| 德钦县| 丹阳市| 郁南县| 琼结县| 锡林郭勒盟| 清镇市| 志丹县| 洛浦县| 华蓥市| 安吉县| 富锦市| 北京市| 阿瓦提县| 龙胜| 饶平县| 韶关市| 开封市| 林芝县| 乌苏市| 五指山市| 红安县| 东明县| 疏附县| 永州市| 横峰县| 鲁甸县| 阜南县| 郯城县| 开鲁县|