unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] guile-readline: Use an empty string if HOME is unset
@ 2014-09-09 21:28 David Michael
  2014-09-10 17:00 ` Eli Zaretskii
  2014-09-22  3:38 ` Mark H Weaver
  0 siblings, 2 replies; 5+ messages in thread
From: David Michael @ 2014-09-09 21:28 UTC (permalink / raw)
  To: guile-devel

* guile-readline/ice-9/readline.scm (history-file): When the HOME
  environment variable is unset, use the empty string in its place.
---

Hi,

If a Guile program uses the readline module without setting HOME, it
will fail due to string-append getting a #f argument.  In particular,
this necessitates workarounds when starting GNU dmd early in the boot
process.  To illustrate this, try:

    guile -c '(use-modules (ice-9 readline))(display "working\n")'

And then:

    env -u HOME \
    guile -c '(use-modules (ice-9 readline))(display "working\n")'

Let me know if there is a better alternative for handling this case, and
I can send another patch.

Thanks.

David


 guile-readline/ice-9/readline.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/guile-readline/ice-9/readline.scm b/guile-readline/ice-9/readline.scm
index 02e68af..0979fd3 100644
--- a/guile-readline/ice-9/readline.scm
+++ b/guile-readline/ice-9/readline.scm
@@ -119,7 +119,8 @@
 (define-once the-readline-port #f)
 
 (define-once history-variable "GUILE_HISTORY")
-(define-once history-file (string-append (getenv "HOME") "/.guile_history"))
+(define-once history-file
+  (string-append (or (getenv "HOME") "") "/.guile_history"))
 
 (define-public readline-port
   (let ((do (lambda (r/w)
-- 
1.9.3



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

* Re: [PATCH] guile-readline: Use an empty string if HOME is unset
  2014-09-09 21:28 [PATCH] guile-readline: Use an empty string if HOME is unset David Michael
@ 2014-09-10 17:00 ` Eli Zaretskii
  2014-09-10 18:06   ` David Michael
  2014-09-22  3:38 ` Mark H Weaver
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2014-09-10 17:00 UTC (permalink / raw)
  To: David Michael; +Cc: guile-devel

> From: David Michael <fedora.dm0@gmail.com>
> Date: Tue, 09 Sep 2014 17:28:42 -0400
> 
> -(define-once history-file (string-append (getenv "HOME") "/.guile_history"))
> +(define-once history-file
> +  (string-append (or (getenv "HOME") "") "/.guile_history"))

Is there any guarantee that the root directory will be writable?

How about "./.guile_history" instead?



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

* Re: [PATCH] guile-readline: Use an empty string if HOME is unset
  2014-09-10 17:00 ` Eli Zaretskii
@ 2014-09-10 18:06   ` David Michael
  2014-09-10 18:23     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: David Michael @ 2014-09-10 18:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: guile-devel

On Wed, Sep 10, 2014 at 1:00 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: David Michael <fedora.dm0@gmail.com>
>> Date: Tue, 09 Sep 2014 17:28:42 -0400
>>
>> -(define-once history-file (string-append (getenv "HOME") "/.guile_history"))
>> +(define-once history-file
>> +  (string-append (or (getenv "HOME") "") "/.guile_history"))
>
> Is there any guarantee that the root directory will be writable?
>
> How about "./.guile_history" instead?

That is okay with me.  Do you want a new patch with s/""/"."/ and
s/empty string/current directory/?

Thanks.

David

P.S.  I resent the patch to bug-guile earlier so it got a bug number.
It's #18439.  Sorry for double-posting.



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

* Re: [PATCH] guile-readline: Use an empty string if HOME is unset
  2014-09-10 18:06   ` David Michael
@ 2014-09-10 18:23     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2014-09-10 18:23 UTC (permalink / raw)
  To: David Michael; +Cc: guile-devel

> Date: Wed, 10 Sep 2014 14:06:15 -0400
> From: David Michael <fedora.dm0@gmail.com>
> Cc: guile-devel@gnu.org
> 
> > How about "./.guile_history" instead?
> 
> That is okay with me.  Do you want a new patch with s/""/"."/ and
> s/empty string/current directory/?

Please wait for others to chime in.  I'm not speaking for the Guile
project, I just expressed my opinion on this.

Thanks.



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

* Re: [PATCH] guile-readline: Use an empty string if HOME is unset
  2014-09-09 21:28 [PATCH] guile-readline: Use an empty string if HOME is unset David Michael
  2014-09-10 17:00 ` Eli Zaretskii
@ 2014-09-22  3:38 ` Mark H Weaver
  1 sibling, 0 replies; 5+ messages in thread
From: Mark H Weaver @ 2014-09-22  3:38 UTC (permalink / raw)
  To: David Michael; +Cc: guile-devel

David Michael <fedora.dm0@gmail.com> writes:
> * guile-readline/ice-9/readline.scm (history-file): When the HOME
>   environment variable is unset, use the empty string in its place.

FYI, this was discussed at <http://bugs.gnu.org/18439>, and we decided
to have guile-readline put .guile_history in the current directory
instead of the filesystem root when neither HOME nor GUILE_HISTORY are
found in the environment.

It's now pushed to stable-2.0, commit
3a3316e200ac49f0e8e9004c233747efd9f54a04.

    Thanks,
      Mark



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

end of thread, other threads:[~2014-09-22  3:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09 21:28 [PATCH] guile-readline: Use an empty string if HOME is unset David Michael
2014-09-10 17:00 ` Eli Zaretskii
2014-09-10 18:06   ` David Michael
2014-09-10 18:23     ` Eli Zaretskii
2014-09-22  3:38 ` Mark H Weaver

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 read-only IMAP folder(s) and NNTP newsgroup(s).