File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! @TERMUX_PREFIX@/bin/bash
2+
3+ set -e -u
4+
5+ show_usage () {
6+ echo " Usage: termux-nfc [-r [short|full]] [-w] [-t [text for TAG] "
7+ echo " read/write data from/to NDEF tag "
8+ echo " -r, read tag "
9+ echo " short, read short information from tag "
10+ echo " full, read full information from tag "
11+ echo " -w, write information on tag "
12+ echo " -t, text for tag"
13+ exit 0
14+ }
15+
16+ ARG_R=" "
17+ OPT_R=" "
18+ ARG_W=" "
19+ OPT_T=" "
20+ ARG_T=" "
21+
22+ PARAM=" "
23+
24+ if [ $# -eq 0 ]; then show_usage; fi
25+
26+ while getopts " :r:t:w" opt
27+ do
28+ case " $opt " in
29+ r) ARG_R=" --es mode read" ; OPT_R=" --es param $OPTARG " ; ;;
30+ w) ARG_W=" --es mode write" ;;
31+ t) ARG_T=" --es param text --es value" ; OPT_T=" $OPTARG " ; ;;
32+ ? ) echo " Error: unknown parameters: $opt $OPTARG ;" ; show_usage; ;;
33+ esac
34+ done
35+
36+
37+ shift $(( OPTIND- 1 ))
38+
39+ if [ " $# " != 0 ]; then echo " Error: too many parameters!" ; show_usage; fi
40+ if [ -n " $ARG_R " ]; then if [ -n " $ARG_W " ]; then echo " Error: Incompatible parameters! \" -r and \" -n" ; show_usage; fi ; fi
41+
42+
43+
44+ if [ -n " $ARG_R " ]; then set -- " $@ " $ARG_R $OPT_R ; fi
45+ if [ -n " $ARG_W " ]; then set -- " $@ " $ARG_W ; fi
46+ if [ -n " $ARG_T " ]; then set -- " $@ " $ARG_T " $OPT_T " ; fi
47+ @TERMUX_PREFIX@/libexec/termux-api Nfc " $@ "
You can’t perform that action at this time.
0 commit comments