bash - testing if input var $1 is encased in single quotes or not -


i have script requires user input text, $ script.sh sometext, need ensure input user types encased in single quotes $ script.sh 'sometext'. can't seem figure out how test quotes.

there other limitations regarding kind of input user can enter, such no spaces , of course no single quotes part of input, both of test reading $1, how read if single quotes, correctly not read bash part of input var $1, used open , close user's input?

you can't tell whether command line written single quotes, double quotes or no quotes, because shell removes them all.

if have script echoit:

#!/bin/bash printf "%s\n" "$@" 

then can run as:

echoit no\ quotes "double quotes" 'single quotes' 

and output be:

no quotes double quotes single quotes 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -