From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#3911: 23.1.50; get-free-disk-space relative to non-existent default-directory Date: Fri, 24 Jul 2009 08:19:54 +1000 Message-ID: <87tz13jb3p.fsf@blah.blah> Reply-To: Kevin Ryde , 3911@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1248388683 18781 80.91.229.12 (23 Jul 2009 22:38:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jul 2009 22:38:03 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 24 00:37:56 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MU6vB-0000bG-4o for geb-bug-gnu-emacs@m.gmane.org; Fri, 24 Jul 2009 00:37:53 +0200 Original-Received: from localhost ([127.0.0.1]:55177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MU6vA-0007Bx-DJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jul 2009 18:37:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MU6v4-0007Bo-Uz for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2009 18:37:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MU6uy-00079f-KB for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2009 18:37:45 -0400 Original-Received: from [199.232.76.173] (port=55862 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MU6uy-00079U-5P for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2009 18:37:40 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:59910) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MU6uw-0000CF-LN for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2009 18:37:39 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n6NMbUkt010388; Thu, 23 Jul 2009 15:37:30 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n6NMP6Dd008177; Thu, 23 Jul 2009 15:25:06 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Kevin Ryde Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 23 Jul 2009 22:25:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 3911 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12483876907823 (code B ref -1); Thu, 23 Jul 2009 22:25:05 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 23 Jul 2009 22:21:30 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n6NMLOj5007682 for ; Thu, 23 Jul 2009 15:21:25 -0700 Original-Received: from mx10.gnu.org ([199.232.76.166]:52480) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1MU6fD-0006qE-BM for emacs-pretest-bug@gnu.org; Thu, 23 Jul 2009 18:21:23 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1MU6f9-00061L-77 for emacs-pretest-bug@gnu.org; Thu, 23 Jul 2009 18:21:21 -0400 Original-Received: from mailout1-1.pacific.net.au ([61.8.2.208]:43106 helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MU6f8-00060X-BN for emacs-pretest-bug@gnu.org; Thu, 23 Jul 2009 18:21:19 -0400 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout1.pacific.net.au (Postfix) with ESMTP id 2BE124FD5DA for ; Fri, 24 Jul 2009 08:21:10 +1000 (EST) Original-Received: from blah.blah (ppp280A.dyn.pacific.net.au [61.8.40.10]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 6A7CB27428 for ; Fri, 24 Jul 2009 08:21:03 +1000 (EST) Original-Received: from gg by blah.blah with local (Exim 4.69) (envelope-from ) id 1MU6do-0002Ax-0S for emacs-pretest-bug@gnu.org; Fri, 24 Jul 2009 08:19:56 +1000 User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.3 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Thu, 23 Jul 2009 18:37:45 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:29594 gmane.emacs.pretest.bugs:24833 Archived-At: --=-=-= On a non-existent directory get-free-disk-space returns nil, eg. (get-free-disk-space "/no/such/dir") => nil But if it's done by a relative path from a default-directory which doesn't exist, then the answer is the space in your home directory (let ((default-directory "/no/such/dir")) (get-free-disk-space ".")) => 3705637 I hoped the two answers would be the same. This is with the "df"-running code in get-free-disk-space, ie. no `file-system-info' function. Perhaps absolutize per below with an inserted setq, the diff being just re-indent. (I still think the use of the home dir there is either complicated and unnecessary, or complicated and necessary everywhere. Or maybe better call-process could not attempt a chdir at all if a caller doesn't care about the current directory. But leaving that unchanged as yet.) 2009-07-24 Kevin Ryde * files.el (get-free-disk-space): Absolutize the dir before changing default-directory, so as not to answer about a different directory. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=files.el.disk-space-absolutize.diff *** files.el 24 Jul 2009 07:35:37 +1000 1.1063 --- files.el 24 Jul 2009 08:07:01 +1000 *************** *** 5394,5410 **** (save-match-data (with-temp-buffer (when (and directory-free-space-program ! (let ((default-directory ! (if (and (not (file-remote-p default-directory)) ! (file-directory-p default-directory) ! (file-readable-p default-directory)) ! default-directory ! (expand-file-name "~/")))) ! (eq (call-process directory-free-space-program ! nil t nil ! directory-free-space-args ! dir) ! 0))) ;; Usual format is a header line followed by a line of ;; numbers. (goto-char (point-min)) --- 5394,5413 ---- (save-match-data (with-temp-buffer (when (and directory-free-space-program ! (progn ! ;; absolutize before changing default-directory ! (setq dir (expand-file-name dir)) ! (let ((default-directory ! (if (and (not (file-remote-p default-directory)) ! (file-directory-p default-directory) ! (file-readable-p default-directory)) ! default-directory ! (expand-file-name "~/")))) ! (eq (call-process directory-free-space-program ! nil t nil ! directory-free-space-args ! dir) ! 0)))) ;; Usual format is a header line followed by a line of ;; numbers. (goto-char (point-min)) --=-=-= In GNU Emacs 23.1.50.4 (i586-pc-linux-gnu, GTK+ Version 2.16.4) of 2009-07-24 on blah.blah configured using `configure 'CFLAGS=-O -g' '--prefix=/down/emacs/b/inst' '--with-x-toolkit=gtk'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_AU value of $XMODIFIERS: nil locale-coding-system: iso-latin-1-unix default-enable-multibyte-characters: t --=-=-=--