URL: https://linuxfr.org/forums/programmation-shell/posts/array-not-found Title: Array not found Authors: Philippe M Date: 2013年06月11日T09:51:09+02:00 License: CC By-SA Tags: Score: 0 Bonjour, Je suis confronté à un problème dont je ne trouve pas la solution. Dans un script je suis amené à utiliser des tableaux pour stocker des valeurs. Sur tout mes serveurs (redhat) ça marche sauf sur un qui n'est pas la même distri (openmediavault). J'ai reproduis le problème avec une version simplifié du script #!/bin/bash bash --version declare -a myarray[0]="hello" declare -a myarray[1]="world" prtinf "${myarray[*]}" printf "\n" Cette version me donne #sh test.sh GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. test.sh: 5: declare: not found test.sh: 6: declare: not found test.sh: 8: Bad substitution Une autre version #!/bin/bash bash --version myarray[0]="hello" myarray[1]="world" prtinf "${myarray[*]}" printf "\n" qui donne #sh test.sh GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. test.sh: 5: myarray[0]=hello: not found test.sh: 6: myarray[1]=world: not found test.sh: 8: Bad substitution Mes autres serveurs sont en version GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc.

AltStyle によって変換されたページ (->オリジナル) /