[ditz-talk] I don't have all the same environment variables as you
Harold Hausman
hhausman at gmail.com
Tue Apr 22 00:48:33 EDT 2008
Hi,
Ditz is awesome. It hits on all the levels I like. Congratulations are
in order. :)
However, ditz makes some assumptions about environment variables that
make it fail not-so-gracefully on some of my machines. (Their
operating systems to remain nameless to protect the otherwise
innocent.)
Something like the following patch might (it's not tested extensively,
or at all really) save some users some trouble.
Thanks for ditz, I'm really enjoying using it.
Regards,
-Harold
$ git diff
diff --git a/lib/model-objects.rb b/lib/model-objects.rb
index 5cd3156..0d696a8 100644
--- a/lib/model-objects.rb
+++ b/lib/model-objects.rb
@@ -251,12 +251,22 @@ class Config < ModelObject
def get_default_name
require 'etc'
- name = Etc.getpwnam(ENV["USER"]).gecos.split(/,/).first
+ begin
+ name = Etc.getpwnam(ENV["USER"]).gecos.split(/,/).first
+ rescue
+ name = "ditzy-user"
+ end
end
def get_default_email
require 'socket'
- email = ENV["USER"] + "@" +
+
+ begin
+ user = ENV["USER"]
+ rescue
+ user = "ditzy-user"
+ end
+ email = user + "@" +
begin
Socket.gethostbyname(Socket.gethostname).first
rescue SocketError
More information about the ditz-talk
mailing list