LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   commands in linux (https://www.linuxquestions.org/questions/linux-newbie-8/commands-in-linux-626962/)

ptcte 03-10-2008 07:45 AM

commands in linux
 
some commands in linux have an underscore at the start(eg. _something).why?

aus9 03-10-2008 08:09 AM

can you provide some examples and in what distro and in what folder pathway pls.

In mdv....I just did a quick check and I have none. AFAIK.

pwc101 03-10-2008 08:44 AM

I have them too, but if I try and run them, I get the following error:
Code:

pwc101@linux:~> _make
_make:compset:158: can only be called from completion function
(eval):1: no matches found: *:all-files
_tags:comptags:36: can only be called from completion function
_tags:comptry:55: can only be called from completion function
_tags:comptags:60: can only be called from completion function
_tags:comptags:67: can only be called from completion function

Code:

pwc101@linux:~> type _make
_make is a shell function

I'm using zsh.

Don't know what it's for, but this is it:
Code:

_make () {
        local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl
        expandVars () {
                local open close var val tmp=$2 ret=$2
                if (( $1 == 0 ))
                then
                        return
                fi
                while :
                do
                        var=${tmp#*\$}
                        if [[ $var != $tmp ]]
                        then
                                tmp=$var
                                case $var in
                                        (\(*) open='('
                                                close=')'  ;;
                                        ({*) open='{'
                                                close='}'  ;;
                                        ([[:alpha:]]*) open=''
                                                close=''
                                                var=${(s::)var[1]}  ;;
                                        (\$*) tmp=${tmp#\$} ;&
                                        (*) continue ;;
                                esac
                                if [[ $open != '' ]]
                                then
                                        var=${var#$open}
                                        var=${var%%$close*}
                                fi
                                case $var in
                                        ([[:alnum:]_]#) val=${(P)var}
                                                val=$(expandVars $(($1 - 1)) $v
al)
                                                ret=${ret//\$$open$var$close/$v
al}  ;;
                                esac
                        else
                                print -- ${ret//\$\$/\$}
                                return
                        fi
                done
        }
        parseMakefile () {
                local input var val TAB=$'\t' dir=$1
                while read input
                do
                        case "$input " in
                                ([[:alnum:]][[:alnum:]_]#[ $TAB]#=*) var=${inpu
t%%[ $TAB]#=*}
                                        val=${input#*=}
                                        val=${val##[ $TAB]#}
                                        eval $var=\$val ;;
                                ([[:alnum:]][[:alnum:]_]#[ $TAB]#:=*) var=${inp
ut%%[ $TAB]#:=*}
                                        val=${input#*=}
                                        val=${val##[ $TAB]#}
                                        val=$(expandVars 10 $val)
                                        eval $var=\$val ;;
                                ([[:alnum:]][^$TAB:=]#:[^=]*) input=${input%%:*
}
                                        print $(expandVars 10 $input) ;;
                                ($incl *) local f=${input##$incl ##}
                                        if [[ $incl = '.include' ]]
                                        then
                                                f=${f#[\"<]}
                                                f=${f%[\">]}
                                        fi
                                        f=$(expandVars 10 $f)
                                        case $f in
                                                (/*)  ;;
                                                (*) f=$dir/$f  ;;
                                        esac
                                        if [ -r $f ]
                                        then
                                                parseMakefile ${f%%/[^/]##} < $
f
                                        fi ;;
                        esac
                done
        }
        findBasedir () {
                local file index basedir
                basedir=$PWD
                for ((index=0; index<$#@; index++)) do
                        if [[ $@[index] = -C ]]
                        then
                                file=${~@[index+1]}
                                if [[ -z $file ]]
                                then
                                        return
                                elif [[ $file = /* ]]
                                then
                                        basedir=$file
                                else
                                        basedir=$basedir/$file
                                fi
                        fi
                done
                print -- $basedir
        }
        _pick_variant -r is_gnu gnu=GNU unix -v -f
        if [[ $is_gnu = gnu ]]
        then
                incl=include
        else
                incl=.include
        fi
        if [[ "$prev" = -[CI] ]]
        then
                _files -W ${(q)$(findBasedir ${words[1,CURRENT-1]})} -/
        elif [[ "$prev" = -[foW] ]]
        then
                _files -W ${(q)$(findBasedir $words)}
        else
                file="$words[(I)-f]"
                if (( file ))
                then
                        file=${~words[file+1]}
                        [[ $file = [^/]* ]] && file=${(q)$(findBasedir $words)}
/$file
                        [[ -r $file ]] || file=
                else
                        local basedir
                        basedir=${(q)$(findBasedir $words)}
                        if [[ $is_gnu = gnu && -r $basedir/GNUmakefile ]]
        else
                file="$words[(I)-f]"
                if (( file ))
                then
                        file=${~words[file+1]}
                        [[ $file = [^/]* ]] && file=${(q)$(findBasedir $words)}
/$file
                        [[ -r $file ]] || file=
                else
                        local basedir
                        basedir=${(q)$(findBasedir $words)}
                        if [[ $is_gnu = gnu && -r $basedir/GNUmakefile ]]
                        then
                                file=$basedir/GNUmakefile
                        elif [[ -r $basedir/makefile ]]
                        then
                                file=$basedir/makefile
                        elif [[ -r $basedir/Makefile ]]
                        then
                                file=$basedir/Makefile
                        else
                                file=''
                        fi
                fi
                if [[ -n "$file" ]] && _tags targets
                then
                        if [[ $is_gnu = gnu ]] && zstyle -t ":completion:${curc
ontext}:targets" call-command
                        then
                                tmp=($(_call_program targets "$words[1]" -nsp -
-no-print-directory -f "$file" .PHONY 2> /dev/null | parseMakefile $PWD))
                        else
                                tmp=($(parseMakefile $PWD < $file))
                        fi
                        _wanted targets expl 'make target' compadd -a tmp && re
turn 0
                fi
                compstate[parameter]="${PREFIX%%\=*}"
                compset -P 1 '*='
                _value "$@"
        fi
}

What a monster!

I have 496 such executables/functions in my PATH.

aus9 03-10-2008 08:51 AM

well normal make is a linear command

./configure
make
make install

done in sequence.

2) i use bash so if root powers....my pathways are in /root/.bashrc.

what file are you referring to pls?

ararus 03-10-2008 12:44 PM

zsh uses a _ prefix for tab completion functions.

You'll find them in /usr/share/zsh/$ZSH_VERSION/functions

hashbangbinbash 03-10-2008 12:53 PM

Quote:

Originally Posted by aus9 (Post 3083887)
well normal make is a linear command

./configure
make
make install

done in sequence.

would this be ok to do that?

Quote:

./configure && make && make install

felixc 03-10-2008 01:11 PM

Yup, that'll produce the same result.

Tinkster 03-10-2008 02:35 PM

Not quite the same. If you line them up in a script they'll all run in
sequence. If you chain them with the double ampersand (&&) the ones to
the right will only execute if the one(s) on the left were successful.

And no, that's not just semantics ;}



Cheers,
Tink

ptcte 03-10-2008 05:23 PM

commands in linux
 
examples are man and _man.Iam using opensuse10.3 and bash with konsole.
when i type man i get what manual page do you want?when i type _man i get bash:COMP_WORDS:bad array subscript.i get these commands listed when press tab twice in bash.

aus9 03-10-2008 05:34 PM

ok found an example of files
http://www.novell.com/products/linux...linux/zsh.html

and zsh calls the (understem) a underscore _

http://www.csse.uwa.edu.au/programmi...oc/zsh_23.html


All times are GMT -5. The time now is 05:58 AM.