bug#17618: ls -l dangerous when listing links (original) (raw)


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


From: Pádraig Brady
Subject: bug#17618: ls -l dangerous when listing links
Date: Wed, 28 May 2014 16:41:52 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

tag 17618 notabug close 17618 stop

On 05/28/2014 02:36 PM, Michał Adamczyk wrote:

Call it a bug or call it a feature. It is dangerous though.

When using ls -l to list a directory with links in it, it will produce an output similar to this:

lrwxrwxrwx 1 user group 30 1980-01-01 00:01 linkname -> /path/to/destination/file

Pretty cool, huh? However, if you select this line and accidentally hit right mouse button, it'll get copied to your prompt. And if you select more than one line, it'll get copied with \n which will get interpreted as if you pushed the Enter.

So the whole line gets interpreted as a command: lrwxrwxrwx [no such command] 1 user group 30 1980-01-01 00:01 linkname - [parameters for non-existing command] > /path/to/destination/file [redirect output to that file]

Since the output is empty, you'll get the target of that link overwritten with an empty file.

My suggestion is to change the representation symbols of link to something that won't get interpreted.

I see the issue. Though I don't think there is anything we can do just to backwards compat. I'm sure there are scripts somewhere depending on the '->' portion. You're free to change that yourself though with a wrapper. See http://www.pixelbeat.org/scripts/l for example which uses '▪▶' instead.

thanks, Pádraig.