-1

This is the script that I have written, only "FOR LOOP" is not working -
Getting this error - Please suggest me how to proceed further.
/var/folders/g9/bgcqz8jn4b7gm47k95f15lvm0000gp/T/jenkins5094260696780533763.sh: line 21: ${~/Library/MobileDevice/Provisioning\ Profiles/}*: bad substitution Build step 'Execute shell' marked build as failure

#!/bin/bash

. ~/.profile
xcode9

security find-identity -p codesigning -v

#ls '/Users/airwatch/Library/MobileDevice/Provisioning Profiles/'

ls ~/Library/MobileDevice/Provisioning\ Profiles/

output=$(ls ~/Library/MobileDevice/Provisioning\ Profiles/ | wc -l)
echo "Total provisioning profiles :" $output

#cat ~/Library/MobileDevice/Provisioning\ Profiles/Accenture_Fit_Distribution.mobileprovision


for entry in "${~/Library/MobileDevice/Provisioning\ Profiles/}*"
do
  echo "$entry"
done
ceving
  • 21,900
  • 13
  • 104
  • 178
  • 3
    What do you expect from `${}` todo? The syntax expects a variable name not a path – jeb Dec 23 '19 at 11:46
  • Requiring a script to source your `.profile` is generally a bad practice. There doesn't seem to be anything in this script which depends on anything from your profile anyway. – tripleee Dec 23 '19 at 12:08

3 Answers3

1

As jeb already explained in his comment, if your write ${...something...} in bash, the ...something... must be a variable name, optionally followed by some parameter substitution (as explained in the section PARAMETERS in the bash man page. In your case, what is written between ${ and } is not a variable name, hence the error.

You probably want something like

for entry in ~/Library/MobileDevice/Provisioning\ Profiles/*
user1934428
  • 19,864
  • 7
  • 42
  • 87
0

Its working for me -

for entry in "$(ls ~/Library/MobileDevice/Provisioning\ Profiles/)" do echo "$entry" done

  • Here, you use `$(ls ....)` instead of `${....}`, as written in your post. This would however produce funny results if `Provisioning Profiles` contained files where the names contain spaces or newlines. In general, the safe (and simplest way) is the one I outlined in my answer. – user1934428 Dec 23 '19 at 11:59
-1

Can you try to change it to something like:

...


dir=~/Library/MobileDevice/Provisioning\ Profiles
for entry in "$dir"/*
do
  echo "$entry"
done

[Update: Fixed error with comments from user1934428]

Bruno
  • 148
  • 8
  • 2
    This would not work. The ~ would not expand to the home directory when used in this way (due to quoting). Also, the spaces around the `=` sign are incorrect. Your solution would work if written as `dir=~/Library/MobileDevice/Provisioning\ Profiles`? – user1934428 Dec 23 '19 at 11:55
  • @user1934428 Yes, true: I tried locally with another folder and before posting here I copy/pasted the line from the original post and messed up the answer. Thanks! – Bruno Dec 23 '19 at 12:05