bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The usage of {0..${#parameter}}


From: Peng Yu
Subject: The usage of {0..${#parameter}}
Date: Wed, 23 Jun 2010 15:27:28 -0500

The commented line in the following bash script is not working. I
notice the following description from man bash and I think that it is
the reason. But I'm not completely sure. Would you please confirm it
for me?

Also, I'm wondering where this decision was made. Can't bash be made
more powerful by allowing the commented line? Will it cause any
problem if such thing is allowed?


#!/usr/bin/env bash

parameter=abcdefg

#for i in {0..${#parameter}};
for i in {0..7};
do
  echo $i ${parameter:$i}
done


       Brace expansion is performed before any other expansions, and any char‐
       acters  special to other expansions are preserved in the result.  It is
       strictly textual.  Bash does not apply any syntactic interpretation  to
       the context of the expansion or the text between the braces.


-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]