Skip to content

Commit

Permalink
Only echo the link if stdout is not a terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
9ary committed Jun 9, 2014
1 parent 96b8677 commit 8ff5dbe
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions mediacrush
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ upload_url() {
}

upload() {
if [ -t 1 ]; then
interactive=true
else
interactive=false
fi

for f in "$@"; do

if [[ -d "$f" ]]; then
Expand All @@ -173,14 +179,20 @@ upload() {
continue
fi

echo -n "Uploading $f ..."
echo -en "\r\033[K"
if [[ "$interactive" == true ]]; then
echo -n "Uploading $f ..."
echo -en "\r\033[K"
fi

if [[ "$dry_run" == "true" ]]; then
if [[ "$is_url" == "true" ]]; then
err "Dry-run not supported for URLs"
else
echo "Uploaded: $server/$hash"
if [[ "$interactive" == true ]]; then
echo "Uploaded: $server/$hash"
else
echo "$server/$hash"
fi
fi
continue
fi
Expand All @@ -199,18 +211,30 @@ upload() {
uploads="$uploads,$hash"
fi

echo "Uploaded: $server/$hash"
if [[ "$interactive" == true ]]; then
echo "Uploaded: $server/$hash"
else
echo "$server/$hash"
fi
done

if [[ "$create_album" == "true" ]]; then
if [[ "$dry_run" == "true" ]]; then
echo "Album: (not available)"
if [[ "$interactive" == true ]]; then
echo "Album: (not available)"
fi
else
echo -n "Creating album..."
echo -en "\r\033[K"
if [[ "$interactive" == true ]]; then
echo -n "Creating album..."
echo -en "\r\033[K"
fi
out=$(send -F "list=$uploads" "$server/api/album/create")
hash=$(get_hash "$out")
echo "Album: $server/$hash"
if [[ "$interactive" == true ]]; then
echo "Album: $server/$hash"
else
echo "$server/$hash"
fi

if [[ "$open_files" == "true" ]]; then
xdg-open "$server/$hash"
Expand Down

0 comments on commit 8ff5dbe

Please sign in to comment.