[TxMt] Help finishing Bundle command

Allan Odgaard throw-away-1 at macromates.com
Sun Apr 2 23:53:16 UTC 2006


On 3/4/2006, at 1:24, Ken Scott wrote:

> if [ "$rv" == "Delete" ]; then
>    eval "$TM_SVN" del "${TM_SELECTED_FILES:-$TM_FILEPATH}"

You should split the last line up into:

    if [[ -n "$TM_SELECTED_FILES" ]];
       then eval "$TM_SVN" del "$TM_SELECTED_FILES"
       else      "$TM_SVN" del "$TM_FILEPATH"
    fi

Because only with TM_SELECTED_FILES do we want to re-evaluate the  
line, after initial variable expansion.

> elif [ "$rv" == "No" ]; then
>     exit
> elif [ "$rv" == "Cancel" ]; then
>     exit
> fi

You can do:

    elif [[ "$rv" == "No" || "$rv" == "Cancel" ]]; then
       exit
    fi

> What I want is the list of files in the CocoaDialog textbox to be  
> newline-separated, and have the enclosing quotes removed (ideally,  
> the project base path as well). I don't have any bash-fu to figure  
> this out.

Here you go. First it converts the variable to a bash array, then it  
iterates over the array, writes the filename with a potential  
$TM_PROJECT_DIRECTORY/ prefix removed.

The CocoaDialog code calls this function and sorts the result (to get  
a sorted file listing).

    file_list () {
       if [[ -n "$TM_SELECTED_FILES" ]]; then
          eval arr=("$TM_SELECTED_FILES")
          for (( i = 0; i < ${#arr[@]}; i++ )); do
             FILE="${arr[$i]}"
             echo "${FILE##$TM_PROJECT_DIRECTORY/}"
          done
       else
          echo "$TM_FILENAME"
       fi
    }

    rv=`CocoaDialog textbox --title "Delete from Repository" \
       --string-output --no-newline --informative-text \
       "These files will be scheduled for deletion during the next  
commit." \
       --text "$(file_list|sort -f)" --button1 "Delete" --button2  
"Cancel"`





More information about the textmate mailing list