Importing functions from a shell script

前端 未结 4 680
南旧
南旧 2020-12-12 14:18

I have a shell script that I would like to test with shUnit. The script (and all the functions) are in a single file since it makes installation much easier.

Example

4条回答
  •  忘掉有多难
    2020-12-12 14:56

    If you are using Bash, another solution may be:

    #!/bin/bash
    
    foo () { ... }
    bar () { ... }
    
    [[ "${FUNCNAME[0]}" == "source" ]] && return
    code
    

提交回复
热议问题