Heyas
With my forum search term 'issue with leading dash' i found 2 closed threads which sadly didnt help me.
Also me was to eager to add the script, that i didnt properly test, and just now figured this issue.
So i have this code:
if [[ -f "$arg" ]]
then while read line
do line="${line/-/'\-'}"
#line="$(echo $line|sed s,{},&\,g)"
line=$(echo "$line"|$SED 's|[%$/\|\]|\\&|g')
tui-echo "$line"
done<"$arg"
else tui-status 1 "File not found: $arg"
fi
I had also tried line=$(echo "$line"|$SED 's|{%$/\|\}|\\&|g')
but that didnt work on the {}
and %
And attempting to print text like:
mv %{name}/docs/* %{buildroot}%{_docdir}/%{name}
mv %{name}/man/*.1 %{buildroot}%{_mandir}/man1
# Lets try once again without this...
rm -fr %{name}/profile.d/tui.sh
#mv %{name}/profile.d/tui.sh %{buildroot}%{_sysconfdir}/profile.d/tui.sh
# Keep for compatiblity
touch %{buildroot}%{_sysconfdir}/profile.d/tui.sh
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%doc %{_docdir}/%{name}/
%{_mandir}/man1/%{name}*.1.gz
%{_datarootdir}/%{name}/
%{_bindir}/%{name}
%{_bindir}/%{name}-*
#%{_sysconfdir}/%{name}/
#%{_sysconfdir}/profile.d/%{name}.sh
%config
%{_sysconfdir}/%{name}/
%{_sysconfdir}/profile.d/%{name}.sh
%{_sysconfdir}/bash_completion.d/%{name}_compl.bash
%changelog
* Wed Jan 21 2015 - Simon A. Erat - erat.simon@gmail.com - 0.6.8-4
- Added: tui-cat, prints a file, also offers typewriter mode
- Updated: tui-new-script, renamed medium to default, added 'tool'
Now the current issue cause the most trouble is the leading -
of the %changelog
section.
But what i get is:
# | mv /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | | #
# | # Lets try once again without this... | #
/bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | rm \-fr /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | # Keep for compatiblity | #
/bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | | #
# | lean | #
/bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | | #
# | 0.000000iles | #
# | 0efattr(\-,root,root,-) | #
/bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | 0oc /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | #/bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | | #
# | onfig | #
/bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | /bin/tui-printf: Zeile 354: printf: `{': Ung�ltiges Formatierungszeichen.
# | | #
# | hangelog | #
# | * Wed Jan 21 2015 \- Simon A. Erat - erat.simon@gmail.com - 0.6.8-4 | #
# | \- Added: tui-cat, prints a file, also offers typewriter mode | #
# | \- Updated: tui-new-script, renamed medium to default, added 'tool' | #
# |
Guess i'll try now a sed instead of a substition on the first line modification, as i just want a leading dash escaped, not every dash.
If that should work, the question on % and {} remains though.
Thank you
---------- Post updated at 12:21 ---------- Previous update was at 12:09 ----------
Changed to:
[[ "-" = "${line:0:1}" ]] && \
line="${line/-/'\-'}"
line=$(echo "$line"|$SED s,'{%}','\\&',g)
But still no luck.
Oh wait... /bin/tui-printf: Zeile 354: printf
cat -n $(which tui-printf) | grep 354 -B3
351 #
352 # Display & Action
353 #
354 printf "${COLOR_LINE_START}${BORDER_LEFT}${COLOR_LINE_IDENT} ${FIRST}${SECOND}${THIRD} ${COLOR_LINE_CLOSE}${BORDER_RIGHT}${COLOR_LINE_END}"
Should i attempt this in tui-printf or in tui-cat?
What troubles me the most is this (inside tui-cat):
- If i dont escape the leading dash, it fails on tui-printf/printf/echo.
- If i escape the leading dash, it prints the escape char too.
Confused.
---------- Post updated at 13:52 ---------- Previous update was at 12:21 ----------
# % works now:
#line=$(echo "$line"|$SED s,'%','%%',g)
#line=$(echo "$line"|$SED s,'%','\%%',g)
#line=$(echo "$line"|$SED s,'\%','\%\%',g)
#line=$(echo "$line"|$SED s,'\%','\\%',g)
line=$(echo "$line"|$SED s,"%","%%",g)
# Fails to preserve, virtual line continueation: \<newline> (eg: [[ condition ]] && \)
#line=$(echo "$line"|$SED s,"\\","\\\\",g)
line=$(echo "$line"|$SED s,'\\','\\\\',g)
# Not there to fix yet
line=$(echo "$line"|$SED s,'{','\{',g)
line=$(echo "$line"|$SED s,'}','\}',g)
tui-echo "$line"
Me out of ideas now, thank you in advance for any ideas.