--bounds not accepting ~ (tilde)

looks like --bounds option does not properly parse path, starting with ~ that took me some time to figure out why it doesn't find the bounds :) -- Rich

Hello Rich, yes, it seems that the shell doesn't replace the ~ when it is used in parameters. Same problem occurs with the coastlinefile option. I think that is acceptable, but we could implement something like path = path.replace("~",System.getProperty("user.home")); Don't know what this will do on a windows system. Gerd
Date: Thu, 14 Feb 2013 12:53:34 +0200 From: richlv@nakts.net To: mkgmap-dev@lists.mkgmap.org.uk Subject: [mkgmap-dev] --bounds not accepting ~ (tilde)
looks like --bounds option does not properly parse path, starting with ~
that took me some time to figure out why it doesn't find the bounds :) -- Rich _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

On Thu, Feb 14, 2013 at 08:36:02PM +0100, Gerd Petermann wrote:
yes, it seems that the shell doesn't replace the ~ when it is used in parameters. Same problem occurs with the coastlinefile option.
I think that is acceptable, but we could implement something
I don't think we should try to replicate any shell functionality. But, if we do not accept java -jar mkgmap.jar --bounds ~/foo then that could be fixed. GNU getopt allows both --long-option=value and --long-option value. Marko

Hi Marko, the parameter is accepted, but you get a file not found error. Gerd
Date: Thu, 14 Feb 2013 22:11:36 +0200 From: marko.makela@iki.fi To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] --bounds not accepting ~ (tilde)
On Thu, Feb 14, 2013 at 08:36:02PM +0100, Gerd Petermann wrote:
yes, it seems that the shell doesn't replace the ~ when it is used in parameters. Same problem occurs with the coastlinefile option.
I think that is acceptable, but we could implement something
I don't think we should try to replicate any shell functionality. But, if we do not accept
java -jar mkgmap.jar --bounds ~/foo
then that could be fixed. GNU getopt allows both --long-option=value and --long-option value.
Marko _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Marko, to be precise: I tested with ubuntu default shell. java -jar mkgmap.jar ~/xyz.osm.pbf works java -jar mkgmap.jar --bounds=~/bounds_20121118.zip xyz.osm gives file not found error for the bounds file Gerd From: gpetermann_muenchen@hotmail.com To: mkgmap-dev@lists.mkgmap.org.uk Date: Thu, 14 Feb 2013 21:15:30 +0100 Subject: Re: [mkgmap-dev] --bounds not accepting ~ (tilde) Hi Marko, the parameter is accepted, but you get a file not found error. Gerd
Date: Thu, 14 Feb 2013 22:11:36 +0200 From: marko.makela@iki.fi To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] --bounds not accepting ~ (tilde)
On Thu, Feb 14, 2013 at 08:36:02PM +0100, Gerd Petermann wrote:
yes, it seems that the shell doesn't replace the ~ when it is used in parameters. Same problem occurs with the coastlinefile option.
I think that is acceptable, but we could implement something
I don't think we should try to replicate any shell functionality. But, if we do not accept
java -jar mkgmap.jar --bounds ~/foo
then that could be fixed. GNU getopt allows both --long-option=value and --long-option value.
Marko _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Gerd,
to be precise: I tested with ubuntu default shell.
java -jar mkgmap.jar ~/xyz.osm.pbf works java -jar mkgmap.jar --bounds=~/bounds_20121118.zip xyz.osm gives file not found error for the bounds file
That would probably be the Bourne again shell (bash), which is the default interactive shell in Debian. It will expand ~ at the start of an argument, but not in the middle. man 1 bash says:
Tilde Expansion If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix.
Note the 'begins with'. IMO the simplest solution would be to accept this syntax if it is not accepted yet: java -jar mkgmap.jar --bounds ~/bounds_20121118.zip xyz.osm Then, the ~ would begin a word, and the shell would expand it. A workaround is to write java -jar mkgmap.jar --bounds="$HOME"/bounds_20121118.zip xyz.osm (I usually use "" around variables in shell scripts, in case the variable value contains $IFS characters, such as spaces. I guess that defining HOME='/home/j. random user' could break some badly written scripts.) Marko

On 2013-02-14 23:48, Marko Mäkelä wrote:
Hi Gerd,
to be precise: I tested with ubuntu default shell.
java -jar mkgmap.jar ~/xyz.osm.pbf works java -jar mkgmap.jar --bounds=~/bounds_20121118.zip xyz.osm gives file not found error for the bounds file
That would probably be the Bourne again shell (bash), which is the default interactive shell in Debian. It will expand ~ at the start of an argument, but not in the middle.
man 1 bash says:
Tilde Expansion If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix.
Note the 'begins with'.
that's different. that part refers to tilde prefix being ~<username> - for example, ~rich would be my home directory, but ~user would be user's home directory. that's not bash specific - it is a unix-specific concept, and it is the current user's home directory. it would be really nice if it was also supported in scenarios like --bounds=~/user/bounds hmm, turns out wikipedia page on tilde even has a section on "computing" :) http://en.wikipedia.org/wiki/Tilde#Directories_and_URLs
IMO the simplest solution would be to accept this syntax if it is not accepted yet:
java -jar mkgmap.jar --bounds ~/bounds_20121118.zip xyz.osm
Then, the ~ would begin a word, and the shell would expand it.
A workaround is to write
java -jar mkgmap.jar --bounds="$HOME"/bounds_20121118.zip xyz.osm
(I usually use "" around variables in shell scripts, in case the variable value contains $IFS characters, such as spaces. I guess that defining HOME='/home/j. random user' could break some badly written scripts.)
Marko -- Rich

Hi, a quick check in the source shows that it is not easy to implement. We have at least these parms to specify a path or file name or a list of them: --style-file --bounds --coastlinefile --input-file --output-dir --license-file --precomp-sea Each parm is handled in its own way, esp. the related checks for file existance etc. A possible solution would be a static utility method like static public File createFile(String path){ if (path.startsWith("~/")) ... return new File(...) } I am not convinced that it's worth all the work. Gerd Rich wrote
On 2013-02-14 23:48, Marko Mäkelä wrote:
Hi Gerd,
to be precise: I tested with ubuntu default shell.
java -jar mkgmap.jar ~/xyz.osm.pbf works java -jar mkgmap.jar --bounds=~/bounds_20121118.zip xyz.osm gives file not found error for the bounds file
That would probably be the Bourne again shell (bash), which is the default interactive shell in Debian. It will expand ~ at the start of an argument, but not in the middle.
man 1 bash says:
Tilde Expansion If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix.
Note the 'begins with'.
that's different. that part refers to tilde prefix being ~ <username> - for example, ~rich would be my home directory, but ~user would be user's home directory.
that's not bash specific - it is a unix-specific concept, and it is the current user's home directory. it would be really nice if it was also supported in scenarios like --bounds=~/user/bounds
hmm, turns out wikipedia page on tilde even has a section on "computing" :)
http://en.wikipedia.org/wiki/Tilde#Directories_and_URLs
IMO the simplest solution would be to accept this syntax if it is not accepted yet:
java -jar mkgmap.jar --bounds ~/bounds_20121118.zip xyz.osm
Then, the ~ would begin a word, and the shell would expand it.
A workaround is to write
java -jar mkgmap.jar --bounds="$HOME"/bounds_20121118.zip xyz.osm
(I usually use "" around variables in shell scripts, in case the variable value contains $IFS characters, such as spaces. I guess that defining HOME='/home/j. random user' could break some badly written scripts.)
Marko -- Rich
mkgmap-dev mailing list
mkgmap-dev@.org
-- View this message in context: http://gis.19327.n5.nabble.com/bounds-not-accepting-tilde-tp5749360p5749496.... Sent from the Mkgmap Development mailing list archive at Nabble.com.

On Thu, Feb 14, 2013 at 10:46:14PM -0800, GerdP wrote:
I am not convinced that it's worth all the work.
Me neither. I would just leave it as is. It is not that hard to write "$HOME" or $HOME instead of ~ if you need it. Instead of typing the commands interactively on the command line, you could write it in a shell script (or .bat file for cmd.exe users) and invoke the script.
man 1 bash says:
Tilde Expansion If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix.
Note the 'begins with'.
that's different. that part refers to tilde prefix being ~ <username>
Not really. I omitted the rest of the paragraph, which included this sentence:
If this login name is the null string, the tilde is replaced with the value of the shell parameter HOME.
that's not bash specific - it is a unix-specific concept, and it is the current user's home directory. it would be really nice if it was also supported in scenarios like --bounds=~/user/bounds
The Unix principle is a loose bunch of simple tools, not duplicating each others' functionality. It is not the job of applications to do stuff like tilde expansion or glob pattern expansion. It is the task of the command line shell. (This may be a bit different in the Microsoft world, as the MS-DOS command.com does not expand glob patterns.) If mkgmap implemented this, what would be next? Brace expansion? http://rgeissert.blogspot.com/2013/01/a-bashism-week-brace-expansion.html For what it is worth, I am a *nix user since 21 years, and my main computing platform has been GNU/Linux (with the Bourne again shell) for about 20 years now. Best regards, Marko
participants (4)
-
Gerd Petermann
-
GerdP
-
Marko Mäkelä
-
Rich