Browse Source

Added a note. Minor fixes.

dev
Franco Masotti 4 years ago
parent
commit
115a1176bc
  1. 12
      _posts/2017-04-24-qemu-ssh-tunnel.md
  2. 15
      _posts/2018-11-18-my-bash-option-parsing-template.md

12
_posts/2017-04-24-qemu-ssh-tunnel.md

@ -1,10 +1,15 @@
---
title: Qemu SSH tunnel
updated: 2017-10-22 18:00
updated: 2018-12-02 18:33
tags: [qemu, vnc, ssh tunnel]
description: How to use qemu via VNC and SSH
---
*Please note that every step described here, except installations and file
configurations have now been integrated directly in the QVM script. For this
reason you should follow the instructions reported on the
[readme file](https://github.com/frnmst/qvm/blob/master/README.md)*
Hello readers,
I was in need to run a virtual machine to do some experiments an `archiso`
@ -152,9 +157,4 @@ Infact, using SSH implies that the traffic between the client and remote server
is encrypted, but using VNC directly by default is NOT so pay
attention.
*Please notice that every step described here, except installations and file
configurations have now been integrated directly in the QVM script. For this
reason you should follow the instructions reported on the
[readme](https://github.com/frnmst/qvm/blob/master/README.md)*
Cheers!

15
_posts/2018-11-18-my-bash-option-parsing-template.md

@ -1,7 +1,7 @@
---
title: My bash template for option parsing
tags: [getopts, bash, template, bashisms, shell]
updated: 2018-11-26 19:40
updated: 2018-12-02 18:33
description: a template for option parsing in Bash based on getopt
---
@ -16,6 +16,11 @@ See [this](https://www.mariusvw.com/2013/02/24/bash-getopt-versus-getopts/)
and [this](http://abhipandey.com/2016/03/getopt-vs-getopts/) for a comparison
between the two.
*Please note that the documentation and source code reported here are old.
Refer to the [fbopt](https://github.com/frnmst/fbopt) repository.*
## Reason
To avoid reinventing the wheel and confusion, I have written some notes and a
dummy script that will serve as template. The script is called `fbopt`, i.e:
*Franco Bash Option Parsing Template*. The purpose of this is to change
@ -47,8 +52,8 @@ These elements should be common sense and not be specific to `fbopt`
|------------|---------|-------|
| constants are enclosed within single quotes | `'constant'` | elements within single quotes (only) are not interpreted by the shell |
| variables enclosed within double quotes | `"${variable}"` | double quotes serve as a delimiter between multiple variable names if these are consecutive. Every variable between the quotes is interpolated |
| variables use the curly braces notation | `"${variable}"` | curly braces serve as a delimiter between multiple variable names if these are consecutive. |
| variables not enclosed within double quotes | `${?}` or `for v in ${values}; do echo "${v}"; done`| the only variables allowed without double quotes are integers (such as return values) and loop iterators (because these won't work otherwise) |
| variables use the curly braces notation | `"${variable}"` | curly braces serve as a delimiter between multiple variable names if these are consecutive |
| variables not enclosed within double quotes | `${?}` or `for v in ${values}; do echo "${v}"; done` | the only variables allowed without double quotes are integers (such as return values) and loop iterators (because these won't work otherwise) |
## Dependencies and compliancy
@ -63,7 +68,7 @@ The template is known to work with the following packages
| Package | Package version | fbopt version |
|---------|-----------------|---------------|
| GNU Bash | `GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)` | `0.1`, `0.2` |
| GNU Bash | `GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)` | `0.1`, `0.2`, `0.3` |
| getopt | `getopt from util-linux 2.33` | `0.1`, `0.2`, `0.3` |
## The template
@ -234,7 +239,7 @@ main()
# Test dependencies and versions.
# getopt must return 4 to be fully compatible. See getopt's manual.
which bash getopt 1>/dev/null 2>/dev/null && { getopt -T; [ $? -eq 4 ]; }
which bash getopt 1>/dev/null 2>/dev/null && { getopt -T; [ ${?} -eq 4 ]; }
# Get and pass argc to the main function.
# All this work with an array must be done to preserve

Loading…
Cancel
Save