Skip to content

Commit

Permalink
Add paste from stdin support
Browse files Browse the repository at this point in the history
  • Loading branch information
PeroSar committed Nov 19, 2021
1 parent fb8bc09 commit 49ec2e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
$ ./rbin.sh -f hello.txt -f bye.txt
```

### Paste from stdin
#### Bash & ZSH
```bash
$ command_that_errors |& ./rbin.sh -f -
```
#### Fish
```fish
$ command_that_errors &| ./rbin.sh -f -
```

### Delete paste(s)
```bash
$ ./rbin.sh -d aBcD.sh
Expand Down
8 changes: 7 additions & 1 deletion rbin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ paste_all() {

for file in "${FILES[@]}"; do

case "$file" in
"-")
local file="/dev/stdin"
;;
esac

local EXT
case "$file" in
*"."*)
Expand All @@ -146,7 +152,7 @@ paste_all() {
esac

# Handle errors if file doesn't exist
if [[ ! -f "$file" ]]; then
if [[ "$file" != "/dev/stdin" && ! -f "$file" ]]; then
bad "File '$file' doesn't exist!"
continue
fi
Expand Down

0 comments on commit 49ec2e6

Please sign in to comment.