coreutils
[Top][All Lists]
Advanced

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

Re: Feature request: ls --hyperlink


From: Pádraig Brady
Subject: Re: Feature request: ls --hyperlink
Date: Fri, 25 Aug 2017 18:27:38 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 25/08/17 13:01, Egmont Koblinger wrote:
> Hi,
> 
>> Version 2 [...]
>> ensures that URLs are aligned in padded output,
> 
> I'm not sure I like this change (the outer pair of single quotes no longer 
> belonging to the URL).
> 
> First, these single quotes are colored according to the file type. With this 
> change, coloring and URLizing became less consistent compared to each other.
> 
> Second, there might be inner apostrophes as well, e.g. on encountering 
> unprintable (e.g. invalid UTF-8) bytes in the filename. These are not nested 
> apostrophes if I understand correctly, but similarly to bash's syntax they 
> are opening-closing alternatively, am I right? In which case matching pairs 
> aren't consistent if they're URLized or not.
> 
> Er... even worse... wait a sec...
> 
> I've created a file named latin1á.txt in Latin-1 environment and listed in 
> UTF-8. Without hyperlink I get
> 
> 'latin1'$'\341''.txt'
> 
> which is plausible. However, with hyperlinks, I get
> 
> 'latin1'$'\341''.txt''
> 
> that is, an extra apostrophe at the end, and an odd number of apostrophes in 
> total. And a correspondingly broken indentation of subsequent columns. Seems 
> like the hyperlink option erroneously adds an extra single quote. (This is 
> with your v2 patch, I haven't checked your v1 in this regard.)

Oops, it needs this change:

diff --git a/src/ls.c b/src/ls.c
index 9ed4913..c1e05a3 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4506,7 +4506,7 @@ quote_name (char const *name, struct quoting_options 
const *options,
   if (stack)
     PUSH_CURRENT_DIRED_POS (stack);

-  fwrite (buf + skip_quotes, 1, len - skip_quotes, stdout);
+  fwrite (buf + skip_quotes, 1, len - (skip_quotes * 2), stdout);

   dired_pos += len;

In general you may be right that I'm over engineering this.
I suppose if the terminals were sensible and only underlined upon hover
then this would be a non issue really.  I'd like to test though.
What's the handiest way for me to get a terminal to test with?
I notice that rawhide doesn't have this change yet.

Re symlinks, it's plausible to encode the link rather than the target,
but that would push the symlink resolution to the consumer
(firefox for example will resolve the symlink and change to the target in the 
URL),
so it wouldn't gain much and may lose some control. I'll think about it.

Thanks for the careful review!
Pádraig



reply via email to

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