Can you safety pin a under layer shirt to keep it tznius together with top layer on Shabbos?
Regarding using safety pins to attach two garment together on shabbos depends on how it is done. The best way to do it would be if it is possible to stick the pin into each layer only once, (close to the edge of the shirts). This would not be considered sewing according to all poskim, as sewing is only when the needle is inserted more than once. If that cannot be done for whatever reason, if it has to be stuck in twice, most poskim permit it, but it is preferred that it be stuck in to the shirt in a way that it will not be kept there for long term. For example, by inserting the pins in a way that they have to be opened in order to remove the shirt, or on a way that the pin is showing and you will not want to keep it there permanently. If that cannot be done then it is may be stuck it in, even twice with the intention that it will not be there permanently.
Korban Nisanel Shabbos 7-50, Sharei Teshuva O:CH 3040-3, M:B 340 27, Chelkas Yackov O:CH 122, Shevet Halevi 4-35, Oz Nidberu 7-36, Be’er Moshe 1-22, Minchas Yitzchok 2-19. However see Igros Moshe 2-84, that there is no tefirah with metal. Also see Chazon Ish O:CH 156 ( additions to Siman 340), Butsater siman 526, (brought in Toras Hamilachos 4- pg. 151), R’ Y. Steif siman 15 that for tznius reasons or to aleiviate pain, that it is permitted. Regarding the opinion of the M:B some poskim are skeptical if this indeed was his opinion see Oz NIdberu 11-21, Tzitz Eliezer 13-43, and 13-43, Emes L’yackov siman 340. Regarding f it isn’t there on a permanent basis see Sharei Teshuva 340-11, Chut Shani Shabbos 1 pg. 136, Shevet Halevi 4-34, Ohr L’tzion 29-5, Shmiras Shabos Khilchoso ( old edition) 15-70, Zachor V’shamor Tofair pg. 8.