.bashrc profile under /etc/skel is broken

Bug #932388 reported by VTKnightMare
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
TurnKey Linux
Fix Released
Low
Alon Swartz
11.x
Fix Released
Undecided
Unassigned
12.x
Fix Released
Low
Alon Swartz
Alon Swartz (alonswartz)
Changed in turnkeylinux:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Alon Swartz (alonswartz)
status: Confirmed → Fix Committed
Revision history for this message
Alon Swartz (alonswartz) wrote :

Thanks for reporting the issue. I committed a fix and it will be included in all new appliances.
You can fix it in current releases with the following diff:

/etc/skel/.bashrc
@@ -30,17 +30,17 @@ fi

 function realpath()
 {
- f=$1
+ f=$@

- if [ -d $f ]; then
+ if [ -d "$f" ]; then
         base=""
- dir=$f
+ dir="$f"
     else
- base="/$(basename $f)"
- dir=$(dirname $f)
+ base="/$(basename "$f")"
+ dir=$(dirname "$f")
     fi

- dir=$(cd $dir && /bin/pwd)
+ dir=$(cd "$dir" && /bin/pwd)

     echo "$dir$base"
 }
@@ -53,10 +53,10 @@ promptpath () {
     # if we are in the home directory
     if echo $realpwd | grep -q "^$realhome"; then
         path=$(echo $realpwd | sed "s|^$realhome|\~|")
- if [ $path = "~" ] || [ $(dirname $path) = "~" ]; then
+ if [ "$path" = "~" ] || [ "$(dirname "$path")" = "~" ]; then
             echo $path
         else
- echo $(basename $(dirname $path))/$(basename $path)
+ echo $(basename $(dirname "$path"))/$(basename "$path")
         fi
         return
     fi
@@ -66,8 +66,8 @@ promptpath () {
     if [ $(dirname $path_dir) = "/" ]; then
         echo $PWD
     else
- path_parent=$(basename $path_dir)
- path_base=$(basename $PWD)
+ path_parent=$(basename "$path_dir")
+ path_base=$(basename "$PWD")

         echo $path_parent/$path_base
     fi

Revision history for this message
tssgery (eric-aceshome) wrote :

Although marked as fixed, I am seeing this behaviour on TKL 12.0 appliances.

To recreated the issue, I have:

1) created a new userid, named "eric"
2) logged in as "eric" and created a directory named "a b" in /home/eric
3) log in as root, and attempted to cd to /home/eric/a\ b

I received the following error:

root@turnkey ~# cd /home/eric/a\ b/
dirname: extra operand `b'
Try `dirname --help' for more information.
dirname: missing operand
Try `dirname --help' for more information.
-bash: [: =: unary operator expected

The contents of /home/eric include:

root@turnkey /home/eric# ls -la
total 56
drwxr-xr-x 8 eric eric 4096 Sep 19 03:27 .
drwxr-xr-x 3 root root 4096 Sep 4 14:49 ..
drwx------ 2 eric eric 4096 Sep 10 00:58 .aptitude
-rw------- 1 eric eric 9747 Sep 19 03:28 .bash_history
-rw-r--r-- 1 eric eric 53 Sep 4 15:25 .gitconfig
-rw-r--r-- 1 eric eric 687 Sep 4 15:27 .profile
-rw-r--r-- 1 eric eric 3995 Sep 4 14:53 .screenrc
drwxrwxr-x 2 eric eric 4096 Sep 4 14:51 .ssh
drwxr-xr-x 2 eric eric 4096 Sep 19 03:27 a b
drwxrwxr-x 2 eric eric 4096 Sep 9 16:03 bin
drwxr-xr-x 12 eric eric 4096 Sep 5 11:43 git
drwxr-xr-x 9 eric eric 4096 Sep 5 14:50 old

Revision history for this message
Alon Swartz (alonswartz) wrote :

Thanks for reporting the issue Eric. I managed to reproduce it and committed a fix. You can apply it to the current version with the following diff of .bashrc:

- path_dir=$(dirname $PWD)
+ path_dir=$(dirname "$PWD")
     # if our parent dir is a top-level directory, don't mangle it
- if [ $(dirname $path_dir) = "/" ]; then
+ if [ $(dirname "$path_dir") = "/" ]; then
         echo $PWD
     else
         path_parent=$(basename "$path_dir")

Revision history for this message
tssgery (eric-aceshome) wrote :

Thanks Alon. The patch seems to have addressed the issue.

Alon Swartz (alonswartz)
Changed in turnkeylinux:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.