edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] glob, wordexp
@ 2014-12-28 19:09 Karl Dahlke
  2014-12-28 19:35 ` Adam Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Dahlke @ 2014-12-28 19:09 UTC (permalink / raw)
  To: Edbrowse-dev

Edbrowse has the feature that you can read or write files using shell variables
and even wildcard expansion, if the result is one file.
I use this feature all the time!

r ~/work/whatever/st*k.c
w $backup/12-25-14.c

and things like that.

Most of this is done by envFile() in stringfile.c,
which is 200 lines of rather awkward code.
I would like to replace most of this with a call to glob or wordexp.
This leverages existing libraries, and is more portable,
since someone else is reading through subdirectories etc.
Are there any reasons I should or should not do this, or any thoughts on this?
I know glob does too little, it doesn't expand shell variables,
but wordexp may do too much,
like all the fancy things bash does to a line.
I need to see how much I can control it with flags.

Karl Dahlke

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Edbrowse-dev] glob, wordexp
  2014-12-28 19:09 [Edbrowse-dev] glob, wordexp Karl Dahlke
@ 2014-12-28 19:35 ` Adam Thompson
  0 siblings, 0 replies; 2+ messages in thread
From: Adam Thompson @ 2014-12-28 19:35 UTC (permalink / raw)
  To: Karl Dahlke; +Cc: Edbrowse-dev

[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]

On Sun, Dec 28, 2014 at 02:09:19PM -0500, Karl Dahlke wrote:
> Edbrowse has the feature that you can read or write files using shell variables
> and even wildcard expansion, if the result is one file.
> I use this feature all the time!
> 
> r ~/work/whatever/st*k.c
> w $backup/12-25-14.c
> 
> and things like that.

Wow, I knew about ~ expansion and env variables but didn't know about wildcards.

> Most of this is done by envFile() in stringfile.c,
> which is 200 lines of rather awkward code.
> I would like to replace most of this with a call to glob or wordexp.
> This leverages existing libraries, and is more portable,
> since someone else is reading through subdirectories etc.

Agreed.
> Are there any reasons I should or should not do this, or any thoughts on this?
> I know glob does too little, it doesn't expand shell variables,
> but wordexp may do too much,
> like all the fancy things bash does to a line.

Yeah, wordexp does massive amounts of things (including command substitution).
Looking through the man page, the only thing you can turn off is the command substitution.
This essentially means that any file names you give it *must* be in legal posix
shell syntax which may or may not be an issue.

I'd say you should go with wordexp (may as well leave in the command
substitution since that could be quite powerful)
as long as you make sure that the readline tab completion feature
yields file names escaped for use in the shell.

On a semi-related note, what're people's thoughts on enabling readline's history feature?
I personally find myself wanting this on an almost daily basis,
but didn't want to do it in case there's a good reason not to.

Cheers,
Adam.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-28 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-28 19:09 [Edbrowse-dev] glob, wordexp Karl Dahlke
2014-12-28 19:35 ` Adam Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).