On Fri, Jun 12, 2020 at 1:36 PM Bram Moolenaar <
Br...@moolenaar.net> wrote:
> Peter Whittaker wrote:
>
> > vimrntm=$(vim --not-a-term -T dumb --cmd 'echo $VIMRUNTIME' --cmd quit | \
> > tr -d '\n\r' |sed -E 's,[^/]+,,')
> >
> > What I'd really like is "vimrntm=$(vim --get-vimruntime)"
>
> I think you already found a way that works:
> vi --not-a-term -c 'echo $VIMRUNTIME' -c q
>
> Why would a command line argument be needed that would do the same
> thing?
It's not exactly doing the same thing: The existing capability
requires post-processing to remove extraneous characters, which isn't
surprising, since those characters aren't extraneous for vim's default
behaviour, which is managing a graphical display. Based on a 10+ year
old example I found online, I hacked together a double pipeline of tr
and sed to remove those characters, but that's definitely ugly, and it
also feels fragile: I'm hardcoding in knowledge of what those
characters are; it works everywhere I need it to right now, but it
feels iffy.
So the difference is that --get-default-runtime would just spit out
exactly that, no screen driving characters; this would be directly
assignable without further filtering.
There should be difference between what is displayed on the screen or
what is written to a file; right now, with the "echo" method, there
is.
My first, simplest thought was to add an appropriate function to
version.c, since version.c already has code to do this it's done as
part of list_version(): list_version() doesn't add the extraneous
format controls (unless it is called as a vim function, e.g., as
":version", not on the command line). It occurs to me we do define a
vim function for this as well.
I started pulling together the list of files that should be changed,
e.g., code, documentation, for both cases. If we decide this is
worthwhile, I'll create a github issue and add the design thoughts and
file list therein, and then bash away at it a while.
Thoughts?
P
Peter Whittaker
EdgeKeep Inc.
www.edgekeep.com