Skip to content

Commit

Permalink
src/winusb: chk_rt_params: Implement check on target_media type
Browse files Browse the repository at this point in the history
Signed-off-by: 林博仁 <[email protected]>
  • Loading branch information
brlin-tw committed Jun 6, 2017
1 parent c324464 commit 183b9fb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/winusb
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ check_runtime_dependencies(){
rm\
readlink\
find\
lsblk
lsblk\
expr
do
if ! command -v "${required_command}" >/dev/null; then
echo_with_color red "${FUNCNAME[0]}: Error: ${APPLICATION_NAME} requires ${required_command} command in the executable search path, but it is not found."
Expand Down Expand Up @@ -585,6 +586,20 @@ check_runtime_parameters(){
exit 1
fi

if [ "${install_mode_ref}" = device ] \
&& expr match "${target_media}" '.*[0-9]' >/dev/null
then
echo_with_color red "${FUNCNAME[0]}: Error: Target media \"${target_media_ref}\" is not an entire storage device!"
exit 1
fi

if [ "${install_mode_ref}" = partition ] \
&& ! expr match "${target_media}" '.*[0-9]' >/dev/null
then
echo_with_color red "${FUNCNAME[0]}: Error: Target media \"${target_media_ref}\" is not an partition!"
exit 1
fi

return 0
}; declare -fr check_runtime_parameters

Expand Down

0 comments on commit 183b9fb

Please sign in to comment.