# shell chdir not working

**URL:** <https://forum.ansible.com/t/shell-chdir-not-working/14127>\
**Category:** Ansible Project\
**Created:** [December 11, 2013, 4:10pm UTC](https://forum.ansible.com/t/shell-chdir-not-working/14127 "2013-12-11T16:10:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [December 11, 2013, 4:10pm UTC](https://forum.ansible.com/t/shell-chdir-not-working/14127/1 "2013-12-11T16:10:58Z")

</div>

I expected the following to init a git repository in /home/youruser/a, but instead it’s created created in /

what am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Scott\_Sturdivant](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Scott\_Sturdivant](https://forum.ansible.com/u/Scott_Sturdivant)\
**Post date:** [December 11, 2013, 4:13pm UTC](https://forum.ansible.com/t/shell-chdir-not-working/14127/2 "2013-12-11T16:13:06Z")

</div>

It’s iterating over your list of items correctly, but by indexing to [0], it’s taking the first char of the item, which happens to be ‘/’. Remove the [0] and you should be fine.

---

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [December 11, 2013, 5:34pm UTC](https://forum.ansible.com/t/shell-chdir-not-working/14127/3 "2013-12-11T17:34:40Z")

</div>

Of course, thanks!
