tags 640272 + patch
thanks

Hi there!

Mixing the reply I was writing after all my tests, something is probably
useless now, but it was already written.

On Sun, 04 Sep 2011 17:33:34 +0200, Axel Beckert wrote:
> Axel Beckert wrote:
>> > It would be very useful to have the possibility to load local file from
>> > CLI similar to w3m, with full or relative paths:
>> > 
>> >   $ conkeror /usr/share/doc/conkeror/copyright
>
> According to upstream, this should work and it actually does work.

Confirmed, I do not understand why yesterday it did not.

>> Yeah, it's very annoying that it doesn't work that way. It though
>> works already this way:
>> 
>>   $ conkeror file:///usr/share/doc/conkeror/copyright
>> 
>> Nevertheless it's annoying that it only works that way.

Here a simple patch, but read below:

--8<---------------cut here---------------start------------->8---
--- /usr/bin/conkeror.ORG       2011-07-19 23:13:31.000000000 +0200
+++ /usr/bin/conkeror   2011-09-04 17:43:37.255077737 +0200
@@ -34,5 +34,21 @@
     errormsg="`exec $XULRUNNER /usr/share/conkeror/application.ini \"$@\" 
2>&1`"
     echo "$errormsg" | sed -e "s:/[^ ]*/xulrunner-bin:$0:; 
/-\(width\|height\)/d" 1>&2
 else
-    exec $XULRUNNER /usr/share/conkeror/application.ini "$@"
+    # loading local file from CLI as w3m/iceweasel
+    # <http://bugs.debian.org/640272>
+    COMMAND="$XULRUNNER /usr/share/conkeror/application.ini"
+    for I in $@; do
+        # check if the argument is not actually an option
+        I_FIRSTCHAR=$(echo "$I" | cut -c 1)
+        # check if it is a full URL or not
+        I_FULLURL=$(echo "$I" | grep "://")
+        if [ "$I_FIRTSCHAR" != - ] && [ ! "$I_FULLURL" ]; then
+            # check if it is a relative or absolute path
+            if [ "$I_FIRSTCHAR" != / ]; then
+                I="$PWD/$I"
+            fi
+        fi
+        COMMAND="$COMMAND $I"
+    done
+    eval "$COMMAND"
 fi
--8<---------------cut here---------------end--------------->8---

NB1, with this patch --help *after* the URL is not anymore recognized
     (see #640321), I still fail to understand why :-(

NB2, while the Debian Policy allows `test -a/-o` (ยง 10.4), I find that
     the other notation is easier to read and it is spotted by
     checkbashisms, feel free to change it to be consistent with line 9

> What I had in mind that doesn't work and what also has been confirmed
> by upstream that this is on purpose is the loading of files with
> _relative_ paths does not work on the commandline. Here's the excerpt
> from IRC:
>
> 17:08:55 <retroj:#conkeror> if you want to open a relative path, just
>                           do: conkeror `pwd`/foo.html

Yeah :-(

> 17:09:26 <retroj:#conkeror> there is a strong reason for not directly
>                           supporting relative paths, which i have
>                           documented at various times when this
>                           question has come up before
> 17:09:52 <XTaran:#conkeror> retroj: Hrm, I think, I have to read them,
>                           but I suspect, I will disagree. :)
> 17:10:10 <XTaran:#conkeror> retroj: It's definitely a violation of the
>                           rule of least surprise...
> 17:10:21 <retroj:#conkeror> what conkeror supports that iceweasel etc
>                           do not is that you can open any url or
>                           webjump from the command line. supporting
>                           relative paths introduces ambiguity into
>                           the system

Deviating from standard (and old common) behavior is even worse.

> 17:12:54 <retroj:#conkeror> it would mean that if you have a file
>                           called "google" in your home directory,
>                           you could not use the google webjump from
>                           the command line
> 17:13:31 <retroj:#conkeror> the solution i'm planning to implement in
>                           decoupling branch is to add a command line
>                           flag that allows opening relative file
>                           paths

It should be the other way around, i.e. a flag for webjumps.

> 17:23:53 <retroj:#conkeror> we have to deal with web addresses, dns
>                           resolution, and webjumps

No, a browser has to deal with URLs, full stop.

>> > Please note that I firstly thought this was a missing feature for all
>> > XULrunner-enabled browser, but actually iceweasel_6.0-1 already
>> > implements this behavior, so reporting to conkeror only.
>> 
>> Yeah, all other browsers I know work that way and that's also the rule
>> of the least surprise.
>
> Still counts. I'll though hesitate to change the default for that in
> the Debian package. I'll probably document how to "fix" it instead as
> soon as I have a working fix.

I firstly thought this was Conkeror's "fault" because of #634721.  So,
let me try to fix that:
=====
luca@gismo:~$ readlink $(which conkeror)
../share/conkeror/conkeror

luca@gismo:~$ ls -l /usr/share/conkeror/
total 64
-rw-r--r-- 1 root root   233 Jul 19 23:15 application.ini
drwxr-xr-x 2 root root  4096 Jul 19 23:35 branding
drwxr-xr-x 2 root root  4096 Jul 19 23:35 chrome
-rw-r--r-- 1 root root  1065 May  4 13:45 chrome.manifest
drwxr-xr-x 2 root root  4096 Jul 19 23:35 components
lrwxrwxrwx 1 root root    38 Sep  4 11:28 conkeror -> 
../../lib/xulrunner-6.0/xulrunner-stub
drwxr-xr-x 2 root root  4096 Jul 19 23:35 content
drwxr-xr-x 5 root root  4096 Feb 17  2011 contrib
drwxr-xr-x 3 root root  4096 Feb 10  2011 defaults
drwxr-xr-x 2 root root  4096 Jul 19 23:35 help
drwxr-xr-x 4 root root  4096 Feb 10  2011 locale
drwxr-xr-x 6 root root 12288 Jul 19 23:35 modules
drwxr-xr-x 2 root root  4096 Jul 19 23:35 search-engines
drwxr-xr-x 3 root root  4096 Feb 10  2011 style
lrwxrwxrwx 1 root root    23 Jul 19 15:35 xulrunner-stub -> 
/usr/bin/xulrunner-stub

luca@gismo:~$ /usr/bin/conkeror
Could not read application.ini
=====

Mmm, second try, mimicking /usr/bin/iceweasel:
=====
luca@gismo$ ls -l /usr/share/conkeror/
total 64
-rw-r--r-- 1 root root   233 Jul 19 23:15 application.ini
drwxr-xr-x 2 root root  4096 Jul 19 23:35 branding
drwxr-xr-x 2 root root  4096 Jul 19 23:35 chrome
-rw-r--r-- 1 root root  1065 May  4 13:45 chrome.manifest
drwxr-xr-x 2 root root  4096 Jul 19 23:35 components
-rwxr-xr-x 1 root root   365 Sep  4 11:36 conkeror
lrwxrwxrwx 1 root root    38 Sep  4 11:28 conkeror-bin -> 
../../lib/xulrunner-6.0/xulrunner-stub
drwxr-xr-x 2 root root  4096 Jul 19 23:35 content
drwxr-xr-x 5 root root  4096 Feb 17  2011 contrib
drwxr-xr-x 3 root root  4096 Feb 10  2011 defaults
drwxr-xr-x 2 root root  4096 Jul 19 23:35 help
drwxr-xr-x 4 root root  4096 Feb 10  2011 locale
drwxr-xr-x 6 root root 12288 Jul 19 23:35 modules
drwxr-xr-x 2 root root  4096 Jul 19 23:35 search-engines
drwxr-xr-x 3 root root  4096 Feb 10  2011 style
lrwxrwxrwx 1 root root    23 Jul 19 15:35 xulrunner-stub -> 
/usr/bin/xulrunner-stub

luca@gismo:~$ cat /usr/share/conkeror/conkeror
#!/bin/sh

MOZ_APP_LAUNCHER="$(which $0)"
MOZ_DIST_BIN="$(dirname "$(readlink -f "${MOZ_APP_LAUNCHER}")")"
MOZ_PROGRAM="${MOZ_DIST_BIN}/conkeror-bin"
export MOZ_APP_LAUNCHER

verbose () {
    if [ "${VERBOSE}" ]; then
        echo $@
    fi
}

# exec wrapper for verbosity
exec_verbose () {
    verbose Running: $@
    exec "$@"
}

exec_verbose ${MOZ_PROGRAM} "$@"

luca@gismo:~$ /usr/bin/conkeror
Could not find the Mozilla runtime.
=====

Something is wrong there, clearly, third and more "complete" try:
=====
luca@gismo$ ls -l /usr/share/conkeror/                                          
                    
total 64
-rw-r--r-- 1 root root   233 Jul 19 23:15 application.ini
drwxr-xr-x 2 root root  4096 Jul 19 23:35 branding
drwxr-xr-x 2 root root  4096 Jul 19 23:35 chrome
-rw-r--r-- 1 root root  1065 May  4 13:45 chrome.manifest
drwxr-xr-x 2 root root  4096 Jul 19 23:35 components
-rwxr-xr-x 1 root root   365 Sep  4 11:36 conkeror
lrwxrwxrwx 1 root root    38 Sep  4 11:28 conkeror-bin -> 
../../lib/xulrunner-6.0/xulrunner-stub
drwxr-xr-x 2 root root  4096 Jul 19 23:35 content
drwxr-xr-x 5 root root  4096 Feb 17  2011 contrib
drwxr-xr-x 3 root root  4096 Feb 10  2011 defaults
drwxr-xr-x 2 root root  4096 Jul 19 23:35 help
drwxr-xr-x 4 root root  4096 Feb 10  2011 locale
drwxr-xr-x 6 root root 12288 Jul 19 23:35 modules
drwxr-xr-x 2 root root  4096 Jul 19 23:35 search-engines
drwxr-xr-x 3 root root  4096 Feb 10  2011 style
lrwxrwxrwx 1 root root    23 Sep  4 11:43 xulrunner -> ../../lib/xulrunner-6.0
lrwxrwxrwx 1 root root    23 Jul 19 15:35 xulrunner-stub -> 
/usr/bin/xulrunner-stub

luca@gismo:~$ /usr/bin/conkeror
Console error: [...]
=====

Bingo!  Unfortunately, the above still does not work for local files:

  $ /usr/bin/conkeror src/Debian/webwml/english/events/index.en.html
    -> <http://www.src.com/Debian/webwml/english/events/index.en.html>

It seems the only option would have been to implement that in the shell
script as per the patch above.  But given all my tests I still think the
problem should be fixed in conkeror upstream, instead, given that
full-path files are opened correctly.  Upstream disagrees, thus feel
free to tag it as wontfix and close it.

Thx, bye,
Gismo / Luca

Attachment: pgpqMA3k8VGKN.pgp
Description: PGP signature

Reply via email to