View Single Post
Old 03-28-2012, 05:02 PM   #24
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773670
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by knc1 View Post
One hint of something to check for in __any__ shell script -
The handling of whitespace.
More correctly, the handling of the "Input Field Seperator" character(s).

Often defined in the "IFS" variable and having the default of "space, tab, new-line" characters.

I can read where G.M. has dealt with space and new-line.
Perhaps tab (\x09) needs to be dealt with also?
One of the FIRST things I tried was defining IFS, but the busybox in the touch had that jiggered such that I could not extract substrings with it. I ended up using ${string:start:length}, but then that did not work on the K3, so I ended up here with "echo|cut". You need to use whatever works, and I want simple code that is not locked to one specific kindle (this script is locked to the K3, for now, but that will change over time).

About handling the tab key, well that would add complexity to my "one page" script, with code that would never get used (the K3 does not have a tab key). Of course, you can make it as complex as you want, if you want to. Just add your name to the credits so I do not get all the blame.

Personally, before publishing, I like to strip out all unessential code, leaving only the elegant essence of the idea I am demonstrating... All the corner-case enhancements that add complexity ARE essential to some life-critical or mission-critical apps, but for demos or simple tools such as this, these safety features are better left out to aid understanding of the essential idea. IFS is one such unessential thing for here...

Last edited by geekmaster; 03-28-2012 at 05:21 PM.
geekmaster is offline   Reply With Quote