Skip to content

Fix "unary operator expected" and "sha1sum: XX: No such file or directory" errors #10

@albertaparicio

Description

@albertaparicio

When inputing S Checker a file with spaces in its name, these errors pop up.

An example of an execution with the -x argument in bash:

bash -x ~/bin/s_checker -s1 -f 05\ Symphonies\ Of\ The\ Planets\ 5.m4a -c 80c0c0f6266fa94c46344faa9f3f672b57a2b01c
+ copyright_notice='schecker (S Checker) v1.2 ©Copyright (C) 2015-2016 Albert Aparicio'
+ mode=
+ checksum=
+ filename=
+ device=
+ '[' 5 -eq 0 ']'
+ '[' -s1 '!=' '' ']'
+ case $1 in
+ mode=SHA1
+ shift
+ '[' -f '!=' '' ']'
+ case $1 in
+ shift
+ filename='05 Symphonies Of The Planets 5.m4a'
+ shift
+ '[' -c '!=' '' ']'
+ case $1 in
+ shift
+ checksum=80c0c0f6266fa94c46344faa9f3f672b57a2b01c
+ shift
+ '[' '' '!=' '' ']'
+ echo ''

+ case $mode in
+ show_data
+ clear

+ echo '███████╗     ██████╗██╗  ██╗███████╗ ██████╗██╗  ██╗███████╗██████╗ 
██╔════╝    ██╔════╝██║  ██║██╔════╝██╔════╝██║ ██╔╝██╔════╝██╔══██╗
███████╗    ██║     ███████║█████╗  ██║     █████╔╝ █████╗  ██████╔╝
╚════██║    ██║     ██╔══██║██╔══╝  ██║     ██╔═██╗ ██╔══╝  ██╔══██╗
███████║    ╚██████╗██║  ██║███████╗╚██████╗██║  ██╗███████╗██║  ██║
╚══════╝     ╚═════╝╚═╝  ╚═╝╚══════╝ ╚═════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
                                                                    '
███████╗     ██████╗██╗  ██╗███████╗ ██████╗██╗  ██╗███████╗██████╗ 
██╔════╝    ██╔════╝██║  ██║██╔════╝██╔════╝██║ ██╔╝██╔════╝██╔══██╗
███████╗    ██║     ███████║█████╗  ██║     █████╔╝ █████╗  ██████╔╝
╚════██║    ██║     ██╔══██║██╔══╝  ██║     ██╔═██╗ ██╔══╝  ██╔══██╗
███████║    ╚██████╗██║  ██║███████╗╚██████╗██║  ██╗███████╗██║  ██║
╚══════╝     ╚═════╝╚═╝  ╚═╝╚══════╝ ╚═════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝

+ echo schecker '(S' 'Checker)' v1.2 ©Copyright '(C)' 2015-2016 Albert Aparicio
schecker (S Checker) v1.2 ©Copyright (C) 2015-2016 Albert Aparicio
+ sum_data
+ echo '
Mode: Checksum checking

Algorithm: SHA1
File: 05 Symphonies Of The Planets 5.m4a
Checksum: 80c0c0f6266fa94c46344faa9f3f672b57a2b01c

Computing checksum...
'

Mode: Checksum checking

Algorithm: SHA1
File: 05 Symphonies Of The Planets 5.m4a
Checksum: 80c0c0f6266fa94c46344faa9f3f672b57a2b01c

Computing checksum...

+ compute_sum sha1sum
+ algorithm=sha1sum
++ sha1sum 05 Symphonies Of The Planets 5.m4a
++ cut -d ' ' -f 1
sha1sum: 05: No such file or directory
sha1sum: Symphonies: No such file or directory
sha1sum: Of: No such file or directory
sha1sum: The: No such file or directory
sha1sum: Planets: No such file or directory
sha1sum: 5.m4a: No such file or directory
+ '[' = 80c0c0f6266fa94c46344faa9f3f672b57a2b01c ']'
/home/albert/bin/s_checker: line 73: [: =: unary operator expected
+ echo '!!--Checksum Mismatch--!!'
!!--Checksum Mismatch--!!
+ exit 0

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions