shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] erro em exemplo do Vitor para o --paned


From: Luiz Alberto
Subject: Re: [shell-script] erro em exemplo do Vitor para o --paned
Date: Fri, 25 Sep 2015 15:39:57 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0

On 25-09-2015 15:20, Alfredo Casanova address@hidden [shell-script] wrote:
 
http://tldp.org/LDP/abs/html/functions.html

The function definition must precede the first call to it. There is no method of "declaring" the function, as, for example, in C.


Você precisa mover a definição da função pra ANTES da primeira chamada dela.

On Fri, Sep 25, 2015 at 3:14 PM address@hidden [shell-script] <address@hidden> wrote:
 

Neste exemplo que o Vitor publicou para o --paned, eu coloquei na minha maquina e quando eu executo da o seguinte erro:
sh: 1: run_find: not found

O que esta errado na minha execucao?
o exemplo e este:

#! /bin/bash

find_cmd='@sh -c "run_find \"%1\" \"%2\" \"%3\" \"%4\" \"%5\""'
export fpipe=$(mktemp -u --tmpdir find.XXXXXXXX)
mkfifo "$fpipe"
#exec 3<> "$fpipe"
fkey=$(($RANDOM * $$))

function run_find
{
    echo "6:@disable@"
    if [[ $2 != TRUE ]]; then
        ARGS="-name '$1'"
    else
        ARGS="-regex '$1'"
    fi
    if [[ -n "$4" ]]; then
        d1=$(date +%j --date="${4//.//}")
        d2=$(date +%j)
        d=$(($d1 - $d2))
        ARGS+=" -ctime $d"
    fi
    if [[ -n "$5" ]]; then
        ARGS+=" -exec grep -E '$5' {} \;"
    fi
    ARGS+=" -printf '%p\n%s\n%M\n%TD %TH:%TM\n%u/%g\n'"
    eval find "$3" $ARGS > "$fpipe"
    echo "6:$find_cmd"
}

export -f run_find


yad --plug="$fkey" --tabnum=1 --form --field="Nome Arquivo" '*' --field="Use regex:chk" '' \
        --field="Diretorio:dir" '' --field="Newer than:dt" '' --field="Valor" '' \
        --field="gtk-find:fbtn" "$find_cmd"  &

cat "$fpipe" | yad --plug="$fkey" --tabnum=2 --list --dclick-action="" \
    --column="Name" --column="Size:num" --column="Perms" --column="Date" --column="Owner" \
    --search-column=1 --expand=column=1 &

yad --paned --key="$fkey" --button="gtk-close:1" --width=700 --height=500 --title="Find files" \
        --window-icon="find"

rm -f "$fpipe"


E não esta dessa forma, pois a função só e mencionada lá em baixo no comando yad e a definição esta antes da chamada

reply via email to

[Prev in Thread] Current Thread [Next in Thread]