bug-bash
[Top][All Lists]
Advanced

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

Re: completion inconsistencies involving symlinks


From: Kartik K. Agaram
Subject: Re: completion inconsistencies involving symlinks
Date: Sun, 10 Sep 2006 04:29:45 -0500 (CDT)

But bash doesn't know whether or not the command only respects physical paths. You have to tell it, and `set -o physical' is the way to do that.

Ah, I finally understood what 'set -o physical' does. Here's my updated
default programmable completion function for various commands now:

  default_complete () {
      set -o physical
      local t1 t2
      COMPREPLY=()

      if [[ "$2" == \$\(* ]]
      then
          t1=${2#??}
          COMPREPLY=(`compgen -c -P '$\(' $t1`)
      fi

      if [ address@hidden -eq 0 ] && [[ "$2" == \$\{* ]]
      then
          t1=${2#??}
          COMPREPLY=(`compgen -v -P '${' -S '}' $t1`)
      fi

      if [ address@hidden -eq 0 ] && [[ "$2" == \$* ]]
      then
          t1=${2#?}
          COMPREPLY=(`compgen -v -P '$' $t1`)
      fi

      if [ address@hidden -eq 0 ] && [[ "$2" == ~* ]] && [[ "$2" != */* ]]
      then
          t1=${2#?}
          COMPREPLY=(`compgen -u -P '~' $t1`)
      fi

      if [ address@hidden -eq 0 ] && [[ "$2" == address@hidden ]]
      then
          address@hidden
          address@hidden
          COMPREPLY=(`compgen -A hostname -P "${t2}@" $t1`)
      fi

      if [ address@hidden -eq 0 ]
      then
          # sh-style glob pattern
          if [[ $2 == *[*?[]* ]]
          then
              COMPREPLY=(`compgen -G "$2"`)
          # ksh-style extended glob pattern - must be complete
          elif shopt -q extglob && [[ $2 == address@hidden(*\)* ]]
          then
              COMPREPLY=(`compgen -G "$2"`)
          fi
      fi

      if [ address@hidden -eq 0 ]
      then
          COMPREPLY=(`compgen -f -- "$2"`)
      fi
      set +o physical
  }

  complete () {
      builtin complete -o default -F default_complete -d $*
  }

The new part is the set -o/+o physical. These completions now seem to work fine for me:
  complete ls cp mv

Thanks!
Kartik




reply via email to

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