Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 1C81F97D956 for ; Fri, 18 Nov 2011 14:12:55 -0400 (AST) Received: from wwwmaster.postgresql.org ([217.196.146.204]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RRSvi-0005L3-Rh for pgsql-bugs@postgresql.org; Fri, 18 Nov 2011 18:12:54 +0000 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id pAIICbct056385 for ; Fri, 18 Nov 2011 18:12:37 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id pAIICbGk056384; Fri, 18 Nov 2011 18:12:37 GMT (envelope-from www) Date: Fri, 18 Nov 2011 18:12:37 GMT Message-Id: <201111181812.pAIICbGk056384@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6301: extra space in psql variable expansion From: "M" Content-Type: text/plain; charset=utf-8 X-Archive-Number: 201111/135 X-Sequence-Number: 31730 The following bug has been logged online: Bug reference: 6301 Logged by: M Email address: sitrash@email.com PostgreSQL version: 8.4.9 Operating system: Linux Description: extra space in psql variable expansion Details: First of all, thank you for supporting a very useful product! When psql expands a :variable into a string it appends a space to the expansion string. For example: psql (8.4.9) Type "help" for help. testdb=> \set my_home /home/crazy testdb=> \echo :my_home/my-script.sql /home/crazy /my-script.sql Note the space between /home/crazy and /my-script.sql in the line above, while there's no space after /home/crazy two lines above where my_home variable is initialized. This prevents use of a variable for storing the directory name where a script to be sourced resides, as in \i :my_dir/my-script.sql because the expanded string contains a space between the expansion of :my_dir and the following /my-script.sql. I believe psql should expand the string :my_dir/my-script.sql into /home/crazy/my-script.sql (note the lack of space between crazy and the following / character). No popular scripting language I'm aware of appends the space character to an expanded variable, so psql's behavior is rather unusual. E.g. ${HOME}/my-script.sql expands into /home/crazy/my-script.sql in a Unix shell script.