bin: better shell quoting for ltlcross and ltldo
* src/bin/common_trans.cc: Use double-quotes when single-quotes cannot do. * src/tests/ltlcross3.test: Add a test case. * NEWS: Mention it.
This commit is contained in:
parent
31f5ea75b2
commit
29052c4619
3 changed files with 43 additions and 6 deletions
2
NEWS
2
NEWS
|
|
@ -36,6 +36,8 @@ New in spot 1.99.1a (not yet released)
|
||||||
- scc_filter() would incorrectly remove Fin marks from
|
- scc_filter() would incorrectly remove Fin marks from
|
||||||
rejecting SCCs.
|
rejecting SCCs.
|
||||||
- the libspotltsmin library is installed
|
- the libspotltsmin library is installed
|
||||||
|
- ltlcross and ltldo did not properly quote atomic propositions
|
||||||
|
and temporary file names containing a single-quote
|
||||||
|
|
||||||
|
|
||||||
New in spot 1.99.1 (2015-06-23)
|
New in spot 1.99.1 (2015-06-23)
|
||||||
|
|
|
||||||
|
|
@ -146,12 +146,39 @@ translator_spec::~translator_spec()
|
||||||
|
|
||||||
std::vector<translator_spec> translators;
|
std::vector<translator_spec> translators;
|
||||||
|
|
||||||
void
|
static void
|
||||||
quoted_string::print(std::ostream& os, const char* pos) const
|
quote_shell_string(std::ostream& os, const char* str)
|
||||||
{
|
{
|
||||||
os << '\'';
|
// Single quotes are best, unless the string to quote contains one.
|
||||||
this->spot::printable_value<std::string>::print(os, pos);
|
if (!strchr(str, '\''))
|
||||||
os << '\'';
|
{
|
||||||
|
os << '\'' << str << '\'';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// In double quotes we have to escape $ ` " or \.
|
||||||
|
os << '"';
|
||||||
|
while (*str)
|
||||||
|
switch (*str)
|
||||||
|
{
|
||||||
|
case '$':
|
||||||
|
case '`':
|
||||||
|
case '"':
|
||||||
|
case '\\':
|
||||||
|
os << '\\';
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
os << *str++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
os << '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
quoted_string::print(std::ostream& os, const char*) const
|
||||||
|
{
|
||||||
|
quote_shell_string(os, val().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
printable_result_filename::printable_result_filename()
|
printable_result_filename::printable_result_filename()
|
||||||
|
|
@ -204,7 +231,7 @@ printable_result_filename::print(std::ostream& os, const char* pos) const
|
||||||
const_cast<printable_result_filename*>(this)->val_
|
const_cast<printable_result_filename*>(this)->val_
|
||||||
= spot::create_tmpfile(prefix);
|
= spot::create_tmpfile(prefix);
|
||||||
}
|
}
|
||||||
os << '\'' << val_ << '\'';
|
quote_shell_string(os, val()->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,14 @@ check_csv()
|
||||||
|
|
||||||
ltl2tgba=../../bin/ltl2tgba
|
ltl2tgba=../../bin/ltl2tgba
|
||||||
|
|
||||||
|
# Make sure ltlcross quotes formulas correctly
|
||||||
|
cat >formula <<\EOF
|
||||||
|
G"a'-'>'b"
|
||||||
|
EOF
|
||||||
|
run 0 ../../bin/ltlcross -F formula --csv=out.csv \
|
||||||
|
"$ltl2tgba -s %f >%N" \
|
||||||
|
"$ltl2tgba --lenient -s %s >%N"
|
||||||
|
|
||||||
run 2 ../../bin/ltlcross "$ltl2tgba -s %f >%N" 'foo bar' 2>stderr -f a
|
run 2 ../../bin/ltlcross "$ltl2tgba -s %f >%N" 'foo bar' 2>stderr -f a
|
||||||
grep 'ltlcross.*no input.*in.*foo bar' stderr
|
grep 'ltlcross.*no input.*in.*foo bar' stderr
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue