aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tmpdir.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-25 16:39:12 +0900
committergit <svn-admin@ruby-lang.org>2022-10-25 07:54:40 +0000
commit114e71d06280f9c57b9859ee4405ae89a989ddb6 (patch)
treec230a311887a725542d42c15c9dd7615ffbe0910 /lib/tmpdir.rb
parent883d9c305f82b23fbe0ed28e9d74461cc5e13b97 (diff)
downloadruby-114e71d06280f9c57b9859ee4405ae89a989ddb6.tar.gz
[ruby/tmpdir] Ignore empty environment variables
Fixes https://github.com/ruby/tmpdir/pull/17 https://github.com/ruby/tmpdir/commit/a79c727a5d
Diffstat (limited to 'lib/tmpdir.rb')
-rw-r--r--lib/tmpdir.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 95d4ca3fce..55920a4a74 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -19,8 +19,10 @@ class Dir
# Returns the operating system's temporary file path.
def self.tmpdir
- ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir = ENV[name]|
- next if !dir
+ ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir|
+ unless dir
+ next if !(dir = ENV[name]) or dir.empty?
+ end
dir = File.expand_path(dir)
stat = File.stat(dir) rescue next
case