trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: February 2012

Re: [trinity-devel] Proposed starttde patch

From: Aleksey Midenkov <midenok@...>
Date: Mon, 27 Feb 2012 10:42:49 +0400
On Mon, Feb 27, 2012 at 5:11 AM, Darrell Anderson
<humanreadable@...> wrote:
> Update starttde consistent with the changes made to tdelibs/tdesu/stub.cpp in bug report 766.
>
> The first snippet that is deleted is redundant and conflicts with the same $PATH test several lines later in the script.
>
> The second change ensures $PATH is consistent with stub.cpp, which places $PREFIX/bin in the path order just before /usr/bin and not blindly as first in the search path. If, oddly, /usr/bin is not in the search path then the script falls back to placing $PREFIX/bin first in the search path.
>
> ==============================================================
> diff -urN tdebase/starttde tdebase.new/starttde
> --- tdebase/starttde  2012-02-15 13:26:30.000000000 -0600
> +++ tdebase.new/starttde  2012-02-26 19:08:44.000000000 -0600
> @@ -76,15 +76,6 @@
>   fi
>  fi
>
> -# In case we have been started with full pathname spec without being in PATH.
> -bindir=`echo "$0" | sed -n 's,^\(/.*\)/[^/][^/]*$,\1,p'`
> -if [ -n "$bindir" ]; then
> -  case $PATH in
> -    $bindir|$bindir:*|*:$bindir|*:$bindir:*) ;;
> -    *) PATH=$bindir:$PATH; export PATH;;
> -  esac
> -fi
> -
>  # Boot sequence:
>  #
>  # tdeinit is used to fork off processes which improves memory usage
> @@ -165,7 +156,14 @@
>  fi
>  if [ -d $TDEDIR/bin ]; then
>   if [ -z "`echo $PATH | grep \"$TDEDIR/bin\"`" ]; then
> -    export PATH=$TDEDIR/bin:$PATH
> +    # Respect the traditional path order. Don't blindly place $TDEDIR/bin
> +    # first in the path. Only place $TDEDIR/bin before /usr/bin. This order is
> +    # consistent with tdelibs/tdesu/stub.cpp.
> +    if [ -n "`echo $PATH | grep \"/usr/bin\"`" ]; then
> +      export PATH="`echo $PATH | sed \"s|/usr/bin|$TDEDIR/bin:/usr/bin|\"`"
> +    else
> +      export PATH=$TDEDIR/bin:$PATH
> +    fi
>   fi
>  fi
>  if [ -d $TDEDIR/share ]; then
> ==============================================================
>
> I have tested the change. If there are no objections then I would like to push the patch.
>
>

The patch has bug. Consider $PATH first containing something like
'/home/me/opt/usr/bin'. Or even that '/usr/bin_strange_backup'. It
must check that '/usr/bin' string is final. That is done with check if
it is in begin of string or have ':' in front and it is in end of
string or have ':' in back.