开发者

Is there a convention for naming 'private functions' in bash?

Is there a convention for naming private functions in bash? I have a bash module with some private functions, wonderi开发者_运维技巧ng if I should start their names with underscore. So far I haven't seen any convention.


For what it's worth, Red Hat's /etc/init.d/functions script uses double underscores.

# __umount_loop awk_program fstab_file first_msg retry_msg umount_args
# awk_program should process fstab_file and return a list of fstab-encoded
# paths; it doesn't have to handle comments in fstab_file.
__umount_loop() {
    # ...
}

# Similar to __umount loop above, specialized for loopback devices
__umount_loopback_loop() {
    # ...
}

# __proc_pids {program} [pidfile]
# Set $pid to pids from /var/run* for {program}.  $pid should be declared
# local in the caller.
# Returns LSB exit code for the 'status' action.
__pids_var_run() {
    # ...
}

# A sed expression to filter out the files that is_ignored_file recognizes
__sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'


I'm not aware of any formal bash-specific conventions, but starting private identifiers with underscore is a fairly widespread language-independent convention (I encountered it on anything from C to Perl to Java to shell scripts).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜