Directly use ${parameter#word} of sh(1) - plumb - Open certain URL patterns with an ad-hoc opener (plumber)
(HTM) hg clone https://bitbucket.org/iamleot/plumb
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset fbb643c5a08aa493f72da86a0c0f9f6907f7dfd7
(DIR) parent 6c04d40595c8c7e761b956420dbb0565b097679a
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sat, 24 Mar 2018 21:36:01
Directly use ${parameter#word} of sh(1)
Apart avoiding printf(1) and cut(1) now the arXiv id does not
contain two extra `//' at the beginning.
Diffstat:
openers/arxiv | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff -r 6c04d40595c8 -r fbb643c5a08a openers/arxiv
--- a/openers/arxiv Sat Mar 24 20:31:08 2018 +0100
+++ b/openers/arxiv Sat Mar 24 21:36:01 2018 +0100
@@ -1,7 +1,7 @@
#!/bin/sh
for u in "$@"; do
- id="$(printf "%s\n" "$u" | cut -d : -f 2)"
+ id="${u#*://}"
pdfurl="https://arxiv.org/pdf/${id}.pdf"
plumb "${pdfurl}"
done