reporting a bug

2022-12-15 Thread yair


function sa {
for y in $(seq $1 $e2); do  
echo "echo search $y " 
done
}



bug description: 
asking to search from 10 to 20 got search from 1 to 10


example:

source test.sh
sa 10 20
echo search 1 
echo search 2 
echo search 3 
echo search 4 
echo search 5 
echo search 6 
echo search 7 
echo search 8 
echo search 9 
echo search 10 



hardware:

uname -a

Linux debian 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 
GNU/Linux
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/";
SUPPORT_URL="https://www.debian.org/support";
BUG_REPORT_URL="https://bugs.debian.org/";


lsb_release -a

Distributor ID: Debian
Description:Debian GNU/Linux 10 (buster)
Release:10
Codename:   buster

hostnamectl

   Static hostname: debian
 Icon name: computer-desktop
   Chassis: desktop
Machine ID: 757eefe5439e4816ba6315c6a0406f07
   Boot ID: 0d421d51b06044ac9ebe33df54ea91cc
  Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 4.19.0-22-amd64
  Architecture: x86-64

bash version:
5.0.3(1)-release


Re: reporting a bug

2022-12-15 Thread Martin Schulte
Hello!

> function sa {
> for y in $(seq $1 $e2); do  
> echo "echo search $y " 
> done
> }

I assume you should write $2 instead of $e2 in line 2.

Best regards,

Martin




Re: reporting a bug

2022-12-15 Thread Andreas Schwab
On Dez 15 2022, y...@liberman.co.il wrote:

> function sa {
> for y in $(seq $1 $e2); do  

The variable e2 is not defined.

> echo "echo search $y " 
> done
> }
>
>
>
> bug description: 
> asking to search from 10 to 20 got search from 1 to 10
>
>
> example:
>
> source test.sh
> sa 10 20

The function ignores the second argument.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Re: reporting a bug

2022-12-15 Thread Greg Wooledge
On Thu, Dec 15, 2022 at 10:55:51AM +, y...@liberman.co.il wrote:
> function sa {
> for y in $(seq $1 $e2); do  
> echo "echo search $y " 
> done
> }

As others have pointed out, you've written $e2 instead of $2.

In addition to that, you're relying on the Linux-specific seq(1)
program, which may not be available on other systems.  You could
use a C-style for loop instead:

function sa {
  local y
  for ((y=$1; y <= $2; y++)); do
echo "echo search $y"
  done
}

This is more portable, as well as more efficient.