シェル変数と関数がどこに設定されているかどうかはどうすればわかりますか?

シェル変数と関数がどこに設定されているかどうかはどうすればわかりますか?

setシステムにコマンドを入力すると、次の内容が抜粋されます。

__colormgr_commandlist='
    create-device
    create-profile
    delete-device
    delete-profile
    device-add-profile
    device-get-default-profile
    device-get-profile-for-qualifier
    device-inhibit
    device-make-profile-default
    device-set-kind
    device-set-model
    device-set-serial
    device-set-vendor
    find-device
    find-device-by-property
    find-profile
    find-profile-by-filename
    get-devices
    get-devices-by-kind
    get-profiles
    get-sensor-reading
    get-sensors
    get-standard-space
    profile-set-filename
    profile-set-qualifier
    sensor-lock
    sensor-set-options
    '
__grub_script_check_program=grub-script-check
_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
_xspecs=([freeamp]="!*.@(mp3|ogg|pls|m3u)" [cdiff]="!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))" [bibtex]="!*.aux" [rgview]="*.@(o|so|so.!(conf|*/*)|a|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [oowriter]="!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm)" [chromium-browser]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [tex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [netscape]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))"
.../..
_xinetd_services () 
{ 
    local xinetddir=/etc/xinetd.d;
    if [[ -d $xinetddir ]]; then
        local restore_nullglob=$(shopt -p nullglob);
        shopt -s nullglob;
        local -a svcs=($( printf '%s\n' $xinetddir/!($_backup_glob) ));
        $restore_nullglob;
        COMPREPLY+=($( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ));
    fi
}
dequote () 
{ 
    eval printf %s "$1" 2> /dev/null
}
quote () 
{ 
    local quoted=${1//\'/\'\\\'\'};
    printf "'%s'" "$quoted"
}
quote_readline () 
{ 
    local quoted;
    _quote_readline_by_ref "$1" ret;
    printf %s "$ret"
}

/etc/profile/etc/environmentおよび/またはなど、私が知っているすべてのファイルを確認しましたが、~/.bashrcビルドスクリプトまたはコード呼び出しが見つかりませんでした。

それはどこから来たアドバイスがありますか?

ベストアンサー1

関数の場合、Bashは関数のソースを知らせることができます。

$ help declare
...
  -F        restrict display to function names only (plus line 
            number and source file when debugging) 

$ shopt -s extdebug
$ declare -F quote_readline
quote_readline 150 /usr/share/bash-completion/bash_completion

(私がこれを見つけたのはstackoverflowへの回答.)

環境変数を見つける良い方法は次のとおりです。環境変数のソースを確認する方法

これらの機能のほとんどはコマンドラインの完成に関連しているようですが、私のUbuntuシステムには上記のような/usr/share/bash-completion/機能が含まれています。

FWIW、__colormgr_commandlist完了とも関連があるようです。これを含むスクリプトがあります。ここ

おすすめ記事