Conversation
Notices
-
Tonight: Learn #Shell scripting pitfalls /w Tim Laurence & #JOSM editing of #OpenStreetMap /w @Andrew_S_Cant https://kwlug.org/node/1098
Monday, 11-Sep-17 15:53:12 EDT from web-
Arrived at !KWLUG. Tim Laurence and @Andrew_S_Cant are arguing about who should present first.
-
Announcements: Upcoming meetings https://kwlug.org/ Astronomy, clusters, Kubernetes, &c.
-
Call For Presentations is closing 1 November for @KWLinuxfest
-
Call For Presentations for @StarConUW is closing this Friday, 15 September 2017. Lightning talks, 1st time presenters encouraged
-
Tim Laurence: "Wow, the #shell does a lot!"
-
Tim Laurence explains how #shell parsing works: how to break up the commands into 'words'
-
In #shell parsing, @variables are substituted, and wildcards* are expanded
-
(of course, in the #shell a variable is expressed with a dollar sign, eg. $variable
-
Now that we know how the #shell breaks down the command, we can find out how it can go wrong
-
Tim Laurence uses some simple example scripts. Nothing's gone wrong yet.
-
Tim Laurence in the wings; @Andrew_S_Cant makes announcements http://sn.jonkman.ca/attachment/68182
-
Tim Laurence now explains inheritance and exporting variables, and return values
-
Tim Laurence: Parameter expansion, eg. ${A:?message} (is it a "variable" or a "parameter"?)
-
Tim Laurence shows that `A='a b c'; echo $A` will print `a b c`, collapsing whitespace. Use doublequotes or set $IFS to '\n\t'
-
#FacePalm. Typing the example here has also collapsed the whitespace. Well, this is a presentation on pitfalls and problems
-
Next examples: Filenames with leading spaces, leading dashes, wildcard characters, embedded spaces
-
And now, "How To Fail A Test": A=0; but [ $A > 1 ] will be true. Why? It's a string comparator.
-
Instead of [ $A > 1 ] use a numeric comparator: [ $A -gt 1 ]
-
Rule of thumb: If comparing strings, use the comparator that looks like a number; if comparing numbers use the comparator made of chars
-
Variables with spaces in the content will also have problems, eg. B='1 2'; [ $B == '1 2' ] is an error
-
And now, the misery of redirecting output to an input file, eg. cat /tmp/text | grep something > /tmp/text
-
And finally, redirecting STDERR to STDOUT, eg. `ls /missing 2>&1 > /tmp/output` vs `ls /missing > /tmp/output 2>&1`
-
Also: use `set -ue` to abort script execution at any error, instead of executing the next command.
-
And `set -x` to show expansions as they occur, useful for debugging
-
There's a lint tool called "shellcheck" to find syntax errors and ambiguities
-
Tim Laurence asks: "Raise your hand if you've written cron jobs. Leave them raised if they worked first try." Nooooobody!
-
Tim Laurence uses `exec` to standardize environment for cron, other people's computers
-
Tim Laurence says to copy the cron $PATH variable in your cron scripts, fixes many problems. Also, cron uses sh so test with sh, not bash
-
Tim Laurence uses `trap` to provide error handling in scripts
-
Q: Does `trap` require `set -e` to abort mid-script? A: Don't know, will test that later.
-
Q: Have you used other shells? A: zsh had lots of eyecandy, zonch and economica are "pythonic". #bash is not the beall & endall
-
Tim Laurence has nice things to say about PowerShell.
-
s/zonch/conch/ in http://sn.jonkman.ca/notice/1573846
-
20 min remaining, 5 min break... @Andrew_S_Cant may have to reprise another night if time runs out.
-
There's an #OpenStreetMap on the screen, @Andrew_S_Cant explains #StatsCan licensed #Canvec data
-
With #Canvec data adding streets is not so important, but adding points of interest and mailboxes
-
Sorry, #Potlatch is the editor built into #OpenStreetMap
-
To limit the amount of data to download, @Andrew_S_Cant pick only a small section of downtown #Kitchener
-
Going to a blank space on the map where @Andrew_S_Cant believes there are buildings to be added
-
Use the existing aerial imagery built into #JOSM, eg. Bing; @Andrew_S_Cant say's they're properly licensed
-
Using the Bing imagery as an overly, @Andrew_S_Cant can see where to create new building objects
-
The other reason for using #JOSM is to use plugins, making things like adding buildings much easier, @Andrew_S_Cant uses "building_tools"
-
Using the #JOSM plugin "building_tools", @Andrew_S_Cant creates a new square where he sees a building.
-
Now @Andrew_S_Cant adds tags to indicate what kind of building it is. Use the #OSM wiki to find out what keywords exist
-
https://wiki.openstreetmap.org/wiki/Key:building tells you what kind of things you can add to buildings
-
And now @Andrew_S_Cant can start adding street numbers for these buildings; !OSM will interpolate the numbers
-
With !OSM you can go into a crazy amount of detail, like num. of floors, bridges between buildings
-
But @Andrew_S_Cant says that's not necessary, just adding buildings is very useful
-
Q: How do you make sure it's correct? A: Many eyes make bugs shallow; the !OSM community will verify and revert if needed
-
Q: Do you add building street address numbers even when interpolation lines exist? A: Not necessary, but when do you remove the interpolation line?
-
Audience reply: Keep the interpolation line always, because it gives a view of street numbers when zoomed out
-
Let @Andrew_S_Cant know if you know of other !OSM projects like mapping little libraries or gender-neutral washrooms, &c
-
That's it! Off to @Abe_Erb for a beverage!
-
Audio: https://kwlug.org/node/1110 Video: https://www.youtube.com/watch?v=Jd_bcZRiMTU and https://www.youtube.com/watch?v=NTjjXpADpyI !KWLUG !Podcasting
-