[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] distinguish local function and global function
From: |
Peng Yu |
Subject: |
[Help-bash] distinguish local function and global function |
Date: |
Mon, 5 Mar 2018 11:17:17 -0600 |
The following example shows that a local function can be defined
within a function. But `type` (as the way that I use it) cannot
distinguish them. Is there a way to tell what functions are local and
what are global?
$ cat main_x1.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
set -v
function cmd {
function cmd1 {
echo xxx
}
type cmd1
cmd1
}
type cmd
cmd
$ ./main_x1.sh
function cmd {
function cmd1 {
echo xxx
}
type cmd1
cmd1
}
type cmd
cmd is a function
cmd ()
{
function cmd1 ()
{
echo xxx
};
type cmd1;
cmd1
}
cmd
cmd1 is a function
cmd1 ()
{
echo xxx
}
xxx
--
Regards,
Peng
- [Help-bash] distinguish local function and global function,
Peng Yu <=