SQLite Forum

sqlite3 .shell - conditional executions with `[[ expr ]]` constructs
Login
Thank you for your efforts and preparing this demonstration.

Now I see I can generate shell script and have it execute actions I want without too much messing with `sqlite3 .shell` meta-command or `dash` peculiarities. 

Maybe I will figure out later, how to generate that all in once oneliner, I was hoping for.

Regarding Warren's suggestion, as of now I am not clear how to apply it in my situation. I have a fossil repo with increasing set of thousands of versioned objects (mostly various documents/scripts, ...) in different "stages". Operations as adding new stuff and extracting, combining different elements of those is gradually evolving, intermingled with manual processing of some documents. I want to derive most actions from info already present in repo, so the idea is to have SELECT generating  those scripts. For simple actions I have SELECT's I wanted to add more conditional logic to it and got stuck with this `bash` `dash`, double bracket, single bracket, and so on fights.

Certainly I love to have this done easier way.

Thanks

```
sqlite> 
sqlite> .output /tmp/furd
sqlite> .print fin=file1.doc
sqlite> .print [[ \"${fin##.}\" = \"doc\" ]]
sqlite> .print echo \"$?\n${fin##.}\"
sqlite> .print echo \"$fin\"
sqlite> .output stdout
sqlite> .shell chmod +x /tmp/furd
sqlite> .shell /bin/bash -c /tmp/furd
1
file1.doc
file1.doc
sqlite> .shell cat /tmp/furd
fin=file1.doc
[[ "${fin##.}" = "doc" ]]
echo "$?
${fin##.}"
echo "$fin"
sqlite> .shell rm /tmp/furd
sqlite>
```