Skip to content

Commit 669d147

Browse files
committed
fix: publish string debug
1 parent 6bd36d3 commit 669d147

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

public/blog/_data.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4926,5 +4926,14 @@
49264926
"web"
49274927
],
49284928
"published": true
4929+
},
4930+
"shell-debugging-vanishing-text": {
4931+
"title": "Debugging vanishing text in shell scripts",
4932+
"date": "2018-10-29 08:23:25",
4933+
"modified": "2018-08-28 17:04:35",
4934+
"tags": [
4935+
"code"
4936+
],
4937+
"published": true
49294938
}
49304939
}

public/drafts/shell-debugging-vanishing-text.md renamed to public/blog/shell-debugging-vanishing-text.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Debugging vanishing text in shell scripts
22

3-
Did you ever get a weird bash scripting issue where a variable would "randomly" eat characters of another command?
3+
Did you ever get a weird bash scripting issue where a variable would "randomly" eat characters of another command?
44

55
No…? Well, I have, quite a few times, so I figured it was time I wrote up my fix.
66

7+
Tools used: `curl`, `awk` and `od`
8+
79
<!--more-->
810

911
## The issue
@@ -20,7 +22,7 @@ curl https://api.tinify.com/shrink -D /dev/stdout \
2022
https://api.tinify.com/output/kdn3bvw6wzb2tqj869n6c5yq0tc34gt9
2123
```
2224

23-
Note that I'm using `printf` in `awk` so that a `\n` isn't added.
25+
Note that I'm using `printf` in `awk` so that a `\n` isn't added.
2426

2527
The second request would do this:
2628

@@ -76,13 +78,15 @@ The final result:
7678
7779
```bash
7880
function shrink() {
81+
# first upload and compress the filename argument
7982
local URL=$(curl https://api.tinify.com/shrink \
8083
--user api:$TINIFY_KEY \
8184
--dump-header /dev/stdout \
8285
--data-binary @$1 | \
8386
awk '/Location/ { gsub(/[[:space:]]+$/, ""); printf $2 }'
8487
)
8588
89+
# then download and overwrite the file with the newly shrunk file
8690
curl -X POST $URL --user api:$TINIFY_KEY --dump-header /dev/stdout --output $1 -H 'content-type: application/json' -d'{"resize":{"method":"scale","width":1320}}'
8791
}
88-
```
92+
```

public/drafts/_data.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,16 +582,6 @@
582582
"code"
583583
]
584584
},
585-
"shell-debugging-vanishing-text": {
586-
"title": "Debugging vanishing text in shell scripts",
587-
"date": "2018-08-28 17:04:35",
588-
"modified": "2018-08-28 17:04:35",
589-
"complete": false,
590-
"inprogress": true,
591-
"tags": [
592-
"code"
593-
]
594-
},
595585
"gym-tech": {
596586
"title": "Gym Tech",
597587
"date": "2018-09-18 07:34:53",

0 commit comments

Comments
 (0)