Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Nvidia, in the past of other companies such as Iagination Technologies, MIPS, Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Friday, October 28, 2016

Bash trap DEBUG does not work inside shell functions - not even to print

Bash Reference Manual:
trap
If a sigspec is DEBUG, the command arg is executed before every simple command, for command, case command, select command, every arithmetic for command, and before the first command executes in a shell function. Refer to the description of the extdebug option to the shopt builtin (see The Shopt Builtin) for details of its effect on the DEBUG trap.


'via Blog this'
This bit me today:



It seems that



  • not only does the bash DEBUG trap not run for commands inside shell functions, but only once at the start
    • which is not unreasonable as a default
    • especially if shopt extdebug allowed you to "trap DEBUG into" shell functions (which I have so far not been able to make work)
  • but "trap ... DEBUG" is actually disabled inside shell functions
    • which means that you cannot have a shell function that formats the current trap status nicely
    • or which tries to add a "trap ... DEBUG" handler to its caller


Unless I can get shopt extdebug to work as advertised - well, at least, as I tyhinik it is advertised - there is a loss of abstraction.



Kluge: pass in the old trap handler setup, compute new, apply outside function.



:-(





A shell session.





    Mac: trap

    trap -- 'shell_session_update' EXIT



It looks like Apple sets up a trap handler by default.



    Mac: trap 'echo DEBUG' DEBUG

    DEBUG



Setting up a trivial (but annoying) DEBUG trap handler.

Run once before any command is run.



    Mac:

    DEBUG



Or even when ENTER is pressed to get a new prompt





    Mac: echo xx

    DEBUG

    xx

    DEBUG



Run twice as set up above, once for the command,

once for the exit handler





Now trying to run trap in a function



    Mac: trap

    DEBUG

    trap -- 'shell_session_update' EXIT

    trap -- 'echo DEBUG' DEBUG

    DEBUG



    Mac: foo() {

    > trap

    > }

    DEBUG



    Mac: foo

    DEBUG

    trap -- 'shell_session_update' EXIT

    DEBUG



The shell function can execute the trap builtin

but the trap DEBUG handler was disabled












Tuesday, October 25, 2016

Pebble, dynamic app swapping

Pebble | Updated Software for Classic Pebbles: "No more 8 app limit"
'via Blog this'
I have the original Pebble.

Originally, this Pebble classic had an 8-app limit.  You could not have more than 8-apps.  This was limiting, but I could live with it.  Although I have played with many apps, I only really use two apps regularly:

(1) the Misfit step counter and sleep tracker - which is supposed to run in the background

(2) the "smart" Gentle Alarm app - which has made waking up almost pleasabnt, because it finds a good time in my sleep cycle to wake me up.

These fit comfortably in the original 8-app limit.


The Pebble SW upgrade that removed the 8-app limit at first seemed not to affect these. But recently...  :-(
  • Repeatedly, including this morning, I switched to my supposedly-always-running Misfit step counter - and I got the progress bar that indicates that the app is not resident on the watch, and is being swapped back in from my phone.
  • At least this morning I had my phone with me.  Unfortunately, I had already walked quite distance, so missed steps 
  • Other times my phone not with me: I often do NOT carry my phone with me on my morning dog walks. So the step counter app hung.  (I live in a canyon - no signal, so it is useless as a phone on my walks. I only carry it occasionally for a podcast player) 
  • One morning I woke up late - the Gentle Alarm app on my Pebble watch had not gone off - and I saw the progress bar that indicates that the app is not resident on the watch, and is trying to swap back in. But I had forgotten to charge my phone, so the watch app was hung trying to swap back in.
This is very unfortunate.  The only two apps that I really want on my watch depend on being present all the time.  There appears to be no way to guarantee that they will not be swapped out.

I have deleted all unnecessary apps.  Factory reset.  But I still seem to get this swapping in  and out.  (I conjecture that Pebble's default apps may swap them out, e.g. for notifications.)

This may be my last straw for the Pebble.  I have been considering buying a FitBit Blaze, even though it lacks smart alarms.  It is sad that software upgrades kill my usage model.

Rant:

Far too many folks assume that everyone always carries their phone with them. False!  Certainly false in the fitness tracker and alarm space.

Apple iPhone and Google Android apps have similarly started to be swapped or paged in from the cloud.   Unfortunately, when you live in a place that does not always have connectivity, sometimes the apps do not work, even though they do not require connectivity except to page.   Even when connected, the apps are slower.